|
From: Peter K. <pk...@us...> - 2001-03-26 11:28:45
|
The following files were modified in apps/bluetooth/sdp_server:
Name Old version New version Comment
---- ----------- ----------- -------
sdp_parser.c 1.14 1.15=20=20=20=20=20=20=20=20=20=20=20=20
sdp_server.c 1.18 1.19=20=20=20=20=20=20=20=20=20=20=20=20
sdp_server.h 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Cleaned up debugging.
The diff of the modified file(s):
--- sdp_parser.c 2001/03/23 16:19:36 1.14
+++ sdp_parser.c 2001/03/26 11:28:41 1.15
@@ -64,49 +64,49 @@
#define SDP_DEBUG_MISC 0
#define SDP_DEBUG_MEM 0
#define SDP_DEBUG_PROC 0
-#define SDP_PRINT_DATA 0
+#define SDP_DEBUG_PRINT_DATA 0
=20
#ifdef BTD_USERSTACK
-#define syslog(x, fmt...) printf(fmt)
+#define syslog(x, fmt...) do { fprintf(stderr, __FILE__ "::"); fprintf(std=
err, fmt); fprintf(stderr, "\n"); } while (0)
#endif
=20
#if SDP_DEBUG_XMIT
-#define D_XMIT(fmt...) syslog(LOG_DEBUG, fmt)
+#define D_XMIT(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_XMIT(fmt...)
#endif
=20
#if SDP_DEBUG_REC
-#define D_REC(fmt...) syslog(LOG_DEBUG, fmt)
+#define D_REC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_REC(fmt...)
#endif
=20
#if SDP_DEBUG_MISC
-#define D_MISC(fmt...) syslog(LOG_DEBUG, fmt)
+#define D_MISC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_MISC(fmt...)
#endif
=20
#if SDP_DEBUG_MEM
-#define D_MEM(fmt...) syslog(LOG_DEBUG, fmt)
+#define D_MEM(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_MEM(fmt...)
#endif
=20
#if SDP_DEBUG_PROC
-#define D_PROC(fmt...) syslog(LOG_DEBUG, fmt)
+#define D_PROC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_PROC(fmt...)
#endif
=20
-#if SDP_PRINT_DATA
-#define PRINTPKT(str, data, len) print_data(str, data, len)
+#if SDP_DEBUG_PRINT_DATA
+#define PRINT_DATA(str, data, len) print_data(str, data, len)
#else
-#define PRINTPKT(str, data, len)
+#define PRINT_DATA(str, data, len)
#endif
=20
-#define D_ERR(fmt...) printf("ERROR :" fmt)
+#define D_ERR(fmt...) do { fprintf(stderr, __FUNCTION__ ": ERROR: " fmt); =
fprintf(stderr, "\n"); } while (0)
=20
#define GET_TYPE(ch) (((ch) >> 3) & 0x1f)
#define GET_SIZE(ch) ((ch) & 0x7)
@@ -156,7 +156,6 @@
void=20
sdp_parse_data(unsigned char* data, unsigned int len)
{
-#define FNC "sdp_parse_data: "
unsigned char id;
unsigned short trans_id;
unsigned short par_len;
@@ -164,7 +163,7 @@
int sdp_con_id;
data_struct *db_hdl;
=20
- PRINTPKT(FNC, data, len);=20=20
+ PRINT_DATA(__FUNCTION__, data, len);
=20
db_hdl =3D (data_struct*)data;
data +=3D sizeof *db_hdl;
@@ -179,12 +178,13 @@
=20
if (par_len > (len - SDP_HDR_SIZE))
{
- D_XMIT(FNC"Packet length does not match received data length par_len %=
d, pkt_len %d\n", par_len, len);
+ D_XMIT("Packet length (%d) does not match received data length (%d)",
+ len - SDP_HDR_SIZE, par_len);
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE);
return;
}
=20
- D_REC(FNC"id:0x%x, trans_id:0x%x, par_len:%d\n", id, trans_id,par_len);
+ D_REC("id: 0x%x, trans_id: 0x%x, par_len: %d", id, trans_id, par_len);
=20
switch (id)
{
@@ -192,73 +192,71 @@
switch (CHAR2INT16(data[5], data[6]))
{
case SDP_INVALID_SDP_VERSION:
- D_ERR(FNC"Got Invalid/unsupported SDP version\n");
+ D_ERR("Got Invalid/unsupported SDP version");
break;
case SDP_INVALID_SERVICE_RECORD_HANDLE:
- D_ERR(FNC"Got Invalid Service Record Handle\n");
+ D_ERR("Got Invalid Service Record Handle");
break;
case SDP_INVALID_REQUEST_SYNTAX:
- D_ERR(FNC"Got Invalid Request Syntax\n");
+ D_ERR("Got Invalid Request Syntax");
break;
case SDP_INVALID_PDU_SIZE:
- D_ERR(FNC"Got Invalid PDU Size\n");
+ D_ERR("Got Invalid PDU Size");
break;
case SDP_INVALID_CONTINUATION_STATE:
- D_ERR(FNC"Got Invalid Continuation State\n");
+ D_ERR("Got Invalid Continuation State");
break;
case SDP_INSUFFICIENT_RESOURCES:
- D_ERR(FNC"Got Insufficient Resources to satisfy Request\n");
+ D_ERR("Got Insufficient Resources to satisfy Request");
break;
default:
- D_ERR(FNC" Error code 0x%04x is not specified\n",
+ D_ERR("Error code 0x%04x is not specified",
CHAR2INT16(data[5], data[6]));
break;
}
break;
=20=09=09
case SDP_SERVICESEARCH_REQ:
- D_REC(FNC"SDP_SERVICESEARCH_REQ %d bytes\n", par_len);
+ D_REC("SDP_SERVICESEARCH_REQ %d bytes", par_len);
process_service_search_req(sdp_con_id, data + 5, par_len, trans_id);
break;
=20=20=20=20=20
case SDP_SERVICESEARCH_RSP:
- D_REC(FNC"SDP_SERVICESEARCH_RSP\n");
+ D_REC("SDP_SERVICESEARCH_RSP");
process_service_search_rsp(sdp_con_id, data + 5);
break;
=20=20=20=20=20
case SDP_SERVICEATTR_REQ:
- D_REC(FNC"SDP_SERVICEATTR_REQ\n");
+ D_REC("SDP_SERVICEATTR_REQ");
process_service_attr_req(sdp_con_id, data + 5, par_len, trans_id);
break;
=20=20=20=20=20
case SDP_SERVICEATTR_RSP:
- D_REC(FNC"SDP_SERVICEATTR_RSP\n");
+ D_REC("SDP_SERVICEATTR_RSP");
process_service_attr_rsp(sdp_con_id, data + 5);
break;
=20=20=20=20=20
case SDP_SERVICESEARCHATTR_REQ:
- D_REC(FNC"SDP_SERVICESEARCHATTR_REQ\n");
+ D_REC("SDP_SERVICESEARCHATTR_REQ");
process_service_search_attr_req(sdp_con_id, data + 5, par_len, trans_i=
d);
break;
=20=20=20=20=20
case SDP_SERVICESEARCHATTR_RSP:
- D_REC(FNC"SDP_SERVICESEARCHATTR_RSP\n");
+ D_REC("SDP_SERVICESEARCHATTR_RSP");
process_service_search_attr_rsp(sdp_con_id, data + 5);
break;
=20=20=20=20=20
default:
- D_REC(FNC"ERROR Invalid pdu type\n");
+ D_REC("ERROR Invalid pdu type");
/* Send an error response with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
break;
}
-#undef FNC
}
=20
void
process_service_search_req(int sdp_con_id, unsigned char *data, unsigned s=
hort len, unsigned int trans_id)
{
-#define FNC "process_service_search_req: "
unsigned int service_search_uuid[12];
int service_search_uuid_cnt;
unsigned char des_len;
@@ -267,10 +265,10 @@
int new_pos[1];
int cont_state_len;
=20=09
- D_REC(FNC"got %d bytes\n", len);
+ D_REC("Got %d bytes", len);
if (GET_TYPE(data[cur_pos]) !=3D DES_TYPE)
{
- D_REC(FNC"Incorrect packet: Data Element Sequence expected\n");
+ D_REC("Incorrect packet: Data Element Sequence expected");
/* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
@@ -278,11 +276,11 @@
=20
des_len =3D get_size(data + cur_pos, new_pos);
cur_pos +=3D *new_pos;
- D_MISC(FNC"des_len: %d, new_pos:%d\n",des_len, *new_pos);
+ D_MISC("des_len: %d, new_pos: %d", des_len, *new_pos);
=20=09
if (des_len > (len - DES_HDR_LEN))
{
- D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was=
not received\n");
+ D_REC("Incorrect packet: Incorrect length field or whole packet was no=
t received");
/* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
@@ -294,9 +292,8 @@
{
if (i >=3D 12)
{
- D_REC(FNC"More than 12 UUID in one request\n");
- /* Send an error msg with error code Invalid request
- syntax */
+ D_REC("More than 12 UUID in one request");
+ /* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
break;
}
@@ -305,8 +302,7 @@
{
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
- D_MISC(FNC"Found UUID16 0x%04x\n",
- service_search_uuid[i]);=20
+ D_MISC("Found UUID16 0x%04x", service_search_uuid[i]);=20
i +=3D 1;
tmp_pos +=3D 3;
cur_pos +=3D 3;
@@ -316,8 +312,7 @@
cur_pos +=3D 2;
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
- D_MISC(FNC"Found UUID32 0x%08x\n",
- service_search_uuid[i]);=20
+ D_MISC("Found UUID32 0x%08x", service_search_uuid[i]);=20
i +=3D 1;
tmp_pos +=3D 5;
cur_pos +=3D 3;
@@ -327,16 +322,15 @@
cur_pos +=3D 2;
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
- D_MISC(FNC"Got Service class 0x%08x\n", service_search_uuid[i]);
+ D_MISC("Got Service class 0x%08x", service_search_uuid[i]);
i +=3D 1;
tmp_pos +=3D 17;
cur_pos +=3D 15;
}
else
{
- D_REC(FNC"Unknown UUID size 0x%02x\n",data[cur_pos]);
- /* Send an error msg with error code Invalid request
- syntax */
+ D_REC("Unknown UUID size 0x%02x", data[cur_pos]);
+ /* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
}
@@ -344,7 +338,7 @@
service_search_uuid_cnt =3D i;
=20
max_rec_cnt =3D CHAR2INT16(data[cur_pos], data[cur_pos + 1]);
- D_MISC(FNC"max_rec_cnt: %d\n", max_rec_cnt);
+ D_MISC("max_rec_cnt: %d", max_rec_cnt);
cur_pos +=3D 2;
=20
cont_state_len =3D data[cur_pos];
@@ -353,13 +347,13 @@
=20
if (len < cur_pos)
{
- D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%=
d cur_pos:%d\n", len, cur_pos);
+ D_ERR("Packet length (%d) shorter than actual packet length (%d)", len=
, cur_pos);
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE);
return;
}
else if (len > cur_pos)
{
- D_ERR(__FUNCTION__", packet len longer than actual packet length len:%=
d cur_pos:%d\n", len, cur_pos);
+ D_ERR("Packet length (%d) longer than actual packet length (%d)", len,=
cur_pos);
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE);
return;
}
@@ -368,7 +362,7 @@
{
cur_pos +=3D data[cur_pos];
=20=20=20=20=20
- D_MISC(FNC"Sending continuationstate packet\n");
+ D_MISC("Sending continuationstate packet");
send_cont_state_search_rsp(cont_state_len, data + cur_pos, max_rec_cnt,
sdp_con_id, trans_id);
}
@@ -388,13 +382,11 @@
/* Here we ask the database for the requested attributes */
handle_query(&db_hdl.db);
}
-#undef FNC
}
=20
void=20
process_service_attr_req(int sdp_con_id, unsigned char *data, unsigned sho=
rt len, int trans_id)
{
-#define FNC "process_service_attr_req: "
service_attr_struct *db_hdl;
=20=09
int tmp_len, cur_pos =3D 0;
@@ -409,21 +401,21 @@
=20=20=20
int new_pos[1];
=20
- D_REC(FNC"got %d bytes\n", len);
+ D_REC("Got %d bytes", len);
=20
rec_hdl =3D CHAR2INT32(data[cur_pos], data[cur_pos + 1],
data[cur_pos + 2], data[cur_pos + 3]);
=20
- D_MISC(FNC"rec_hdl: 0x%08x\n",rec_hdl);
+ D_MISC("rec_hdl: 0x%08x", rec_hdl);
cur_pos +=3D 4;
=20
max_attr_cnt =3D CHAR2INT16(data[cur_pos], data[cur_pos + 1]);
- D_MISC(FNC"max_attr_cnt: %d\n",max_attr_cnt);
+ D_MISC("max_attr_cnt: %d", max_attr_cnt);
cur_pos +=3D 2;
=20
if (GET_TYPE(data[cur_pos]) !=3D DES_TYPE)
{
- D_REC(FNC"Incorrect packet: Data Element Sequence expected\n");
+ D_REC("Incorrect packet: Data Element Sequence expected");
/* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
@@ -431,11 +423,11 @@
=20
des_len =3D get_size(data + cur_pos, new_pos);
cur_pos +=3D *new_pos;
- D_MISC(FNC"des_len: %d, new_pos:%d\n",des_len, *new_pos);
+ D_MISC("des_len: %d, new_pos: %d", des_len, *new_pos);
=20=09
if (des_len > (len - DES_HDR_LEN))
{
- D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was=
not received\n");
+ D_REC("Incorrect packet: Incorrect length field or whole packet was no=
t received");
/* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
@@ -448,7 +440,7 @@
{
/* Get the length of the data element */
tmp_len =3D get_size(data + cur_pos, new_pos);
- D_MISC(FNC"tmp_len: %d, new_pos: %d\n", tmp_len, *new_pos);
+ D_MISC("tmp_len: %d, new_pos: %d", tmp_len, *new_pos);
/* Move the data pointer past the length field to the start of
the data element */
cur_pos +=3D *new_pos;
@@ -456,8 +448,7 @@
{
/* Now we got a range of attributes */
attr_list[attr_list_pos] =3D CHAR2INT32(data[cur_pos], data[cur_pos =
+ 1], data[cur_pos + 2], data[cur_pos + 3]);
- D_MISC(FNC"Found range of attributes: 0x%08x\n",
- attr_list[attr_list_pos]);=20
+ D_MISC("Found range of attributes: 0x%08x", attr_list[attr_list_pos]=
);=20
cur_pos +=3D 4;
attr_list_pos +=3D 1;
}
@@ -467,8 +458,7 @@
attr_list[attr_list_pos] =3D CHAR2INT16(data[cur_pos], data[cur_pos =
+ 1]);
/* We stor all attributes as ranges */
attr_list[attr_list_pos] |=3D attr_list[attr_list_pos] << 16;
- D_MISC(FNC"Found single attributes: 0x%04x\n",
- attr_list[attr_list_pos]);=20
+ D_MISC("Found single attributes: 0x%04x", attr_list[attr_list_pos]);=
=20
cur_pos +=3D 2;
attr_list_pos +=3D 1;=09
}
@@ -480,20 +470,20 @@
=20
if (len < cur_pos)
{
- D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%=
d cur_pos:%d\n", len, cur_pos);
+ D_ERR("Packet length (%d) shorter than actual packet length (%d)", len=
, cur_pos);
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE);
return;
}
else if (len > cur_pos)
{
- D_ERR(__FUNCTION__", packet len longer than actual packet length len:%=
d cur_pos:%d\n", len, cur_pos);
+ D_ERR("Packet length (%d) longer than actual packet length (%d)", len,=
cur_pos);
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE);
return;
}
=20=20=20
if (cont_state_len)
{
- D_MISC(FNC"Sending continuationstate packet\n");
+ D_MISC("Sending continuationstate packet");
send_cont_state_attr_rsp(cont_state_len, data + cur_pos, max_attr_cnt,
sdp_con_id, trans_id);
}
@@ -502,12 +492,12 @@
len =3D sizeof(service_attr_struct) + attr_list_pos * sizeof *attr_lis=
t;
=20=09
if (!(db_hdl =3D malloc(len))) {
- D_ERR(__FUNCTION__ ": malloc failed to allocate %d bytes!\n", =
len);
+ D_ERR("malloc failed to allocate %d bytes!", len);
send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCE=
S);
return;
}
=20
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, len, (int)db=
_hdl);
+ D_MEM("---> malloc%d %d bytes at 0x%08x", malloc_dbg++, len, (int)db_h=
dl);
=20=20=20=20=20
db_hdl->db.sdp_con_id =3D sdp_con_id;
db_hdl->db.trans_id =3D trans_id;
@@ -522,19 +512,15 @@
=20
handle_query(&db_hdl->db);
=20=20=20=20=20
- D_MEM("<--- free%d 0x%08x\n", malloc_dbg--, (int) db_hdl);
+ D_MEM("<--- free%d 0x%08x", --malloc_dbg, (int) db_hdl);
free(db_hdl);
}
-=09
-#undef FNC
}
=20
void=20
process_service_search_attr_req(int sdp_con_id, unsigned char *data, unsig=
ned short len,int trans_id)
{
-#define FNC "process_service_search_attr_req: "
service_search_attr_struct *db_hdl;
-=09
unsigned int service_search_uuid[12];
int service_search_uuid_cnt;
unsigned char des_len;
@@ -543,14 +529,12 @@
int new_pos[1];
unsigned int attr_list[256];
int attr_list_pos =3D 0;
-
unsigned char cont_state_len;
-
=20
- D_REC(FNC"got %d bytes\n", len);
+ D_REC("Got %d bytes", len);
if (GET_TYPE(data[cur_pos]) !=3D DES_TYPE)
{
- D_REC(FNC"Incorrect packet: Data Element Sequence expected\n");
+ D_REC("Incorrect packet: Data Element Sequence expected");
/* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
@@ -558,11 +542,11 @@
=20
des_len =3D get_size(data + cur_pos, new_pos);
cur_pos +=3D *new_pos;
- D_MISC(FNC"des_len: %d, new_pos:%d\n",des_len, *new_pos);
+ D_MISC("des_len: %d, new_pos: %d", des_len, *new_pos);
=20=09
if (des_len > (len - DES_HDR_LEN))
{
- D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was=
not received\n");
+ D_REC("Incorrect packet: Incorrect length field or whole packet was no=
t received");
/* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
@@ -574,7 +558,7 @@
{
if (i >=3D 12)
{
- D_REC(FNC"More than 12 UUID in one request\n");
+ D_REC("More than 12 UUID in one request");
break;
}
=20=09=09
@@ -582,7 +566,7 @@
{
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
- D_MISC(FNC"Got Service class 0x%04x\n", service_search_uuid[i]);
+ D_MISC("Got Service class 0x%04x", service_search_uuid[i]);
i +=3D 1;
tmp_pos +=3D 3;
cur_pos +=3D 3;
@@ -592,7 +576,7 @@
cur_pos +=3D 2;
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
- D_MISC(FNC"Got Service class 0x%08x\n", service_search_uuid[i]);
+ D_MISC("Got Service class 0x%08x", service_search_uuid[i]);
i +=3D 1;
tmp_pos +=3D 5;
cur_pos +=3D 3;
@@ -602,14 +586,14 @@
cur_pos +=3D 2;
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
- D_MISC(FNC"Got Service class 0x%08x\n", service_search_uuid[i]);
+ D_MISC("Got Service class 0x%08x", service_search_uuid[i]);
i +=3D 1;
tmp_pos +=3D 17;
cur_pos +=3D 15;
}
else
{
- D_REC(FNC"Unknown UUID size 0x%02x\n",data[cur_pos]);
+ D_REC("Unknown UUID size 0x%02x", data[cur_pos]);
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
}
@@ -617,12 +601,12 @@
service_search_uuid_cnt =3D i;
=20
max_attr_cnt =3D CHAR2INT16(data[cur_pos], data[cur_pos + 1]);
- D_MISC(FNC"max_attr_cnt: %d\n",max_attr_cnt);
+ D_MISC("max_attr_cnt: %d", max_attr_cnt);
cur_pos +=3D 2;
=20
if (GET_TYPE(data[cur_pos]) !=3D DES_TYPE)
{
- D_REC(FNC"Incorrect packet: Data Element Sequence expected\n");
+ D_REC("Incorrect packet: Data Element Sequence expected");
/* Send an error msg with error code Invalid request syntax */
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX);
return;
@@ -630,8 +614,7 @@
=20
des_len =3D get_size(data + cur_pos, new_pos);
cur_pos +=3D *new_pos;
- D_MISC(FNC"des_len: %d, new_pos:%d\n",des_len, *new_pos);
-
+ D_MISC("des_len: %d, new_pos: %d", des_len, *new_pos);
=20
/* Now we parses the third parameter which is a data element list. i.e
we have to go through the whole list and pick out one element at
@@ -640,7 +623,7 @@
{
/* Get the length of the data element */
tmp_len =3D get_size(data + cur_pos, new_pos);
- D_MISC(FNC"tmp_len: %d, new_pos: %d\n", tmp_len, *new_pos);
+ D_MISC("tmp_len: %d, new_pos: %d", tmp_len, *new_pos);
/* Move the data pointer past the length field to the start of
the data element */
cur_pos +=3D *new_pos;
@@ -650,8 +633,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(FNC"Found range of attributes: 0x%08x\n",
- attr_list[attr_list_pos]);=20
+ D_MISC("Found range of attributes: 0x%08x", attr_list[attr_list_pos]=
);=20
cur_pos +=3D 4;
attr_list_pos +=3D 1;
}
@@ -661,7 +643,7 @@
attr_list[attr_list_pos] =3D CHAR2INT16(data[cur_pos], data[cur_pos =
+ 1]);
/* We stor all attributes as ranges */
attr_list[attr_list_pos] |=3D attr_list[attr_list_pos] << 16;
- D_MISC(FNC"Found single attributes: 0x%04x\n",
+ D_MISC("Found single attributes: 0x%04x",
(attr_list[attr_list_pos]) & 0xffff);=20
cur_pos +=3D 2;
attr_list_pos +=3D 1;=09
@@ -674,20 +656,20 @@
=20
if (len < cur_pos)
{
- D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%=
d cur_pos:%d\n", len, cur_pos);
+ D_ERR("Packet length (%d) shorter than actual packet length (%d)", len=
, cur_pos);
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE);
return;
}
else if (len > cur_pos)
{
- D_ERR(__FUNCTION__", packet len longer than actual packet length len:%=
d cur_pos:%d\n", len, cur_pos);
+ D_ERR("Packet length (%d) longer than actual packet length 8%d)", len,=
cur_pos);
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE);
return;
}
=20=20=20
if (cont_state_len)
{
- D_MISC(FNC"Sending continuationstate packet\n");
+ D_MISC("Sending continuationstate packet");
send_cont_state_attr_rsp(cont_state_len, data + cur_pos, max_attr_cnt,
sdp_con_id, trans_id);
}
@@ -696,12 +678,12 @@
tmp_len =3D sizeof(service_search_attr_struct) + attr_list_pos * sizeo=
f *attr_list;
=20=09
if (!(db_hdl =3D malloc(tmp_len))) {
- D_ERR(__FUNCTION__ ": malloc failed to allocate %d bytes!\n", =
tmp_len);
+ D_ERR("malloc failed to allocate %d bytes!", tmp_len);
send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCE=
S);
return;
}
=20
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, tmp_len, (in=
t) db_hdl);
+ D_MEM("---> malloc%d %d bytes at 0x%08x", malloc_dbg++, tmp_len, (int)=
db_hdl);
=20=20=20=20=20
db_hdl->db.sdp_con_id =3D sdp_con_id;
db_hdl->db.trans_id =3D trans_id;
@@ -716,41 +698,29 @@
/* Here we ask the database for the requested attributes */
handle_query(&db_hdl->db);
=20
- D_MEM("<--- free%d 0x%08x\n", malloc_dbg--, (int) db_hdl);
+ D_MEM("<--- free%d 0x%08x", --malloc_dbg, (int) db_hdl);
free(db_hdl);
}
-=09=09
-#undef FNC=09
}
=20
void
process_service_search_rsp(int sdp_con_id, unsigned char *data)
{
-#define FNC "process_service_search_rsp: "
-=09
-#undef FNC=09
}
=20
void=20
process_service_attr_rsp(int sdp_con_id, unsigned char *data)
{
-#define FNC "process_service_attr_rsp: "
-=09
-#undef FNC
}
=20
void
process_service_search_attr_rsp(int sdp_con_id, unsigned char *data)
{
-#define FNC "process_service_search_attr_rsp: "
-=09
-#undef FNC=09
}
=20
void
send_error_rsp(int sdp_con_id, unsigned short trans_id, unsigned short err=
_code)
{
-#define FNC "send_error_rsp: "
unsigned char sdp_data[7];
unsigned short pdu_len;
=20
@@ -769,8 +739,6 @@
sdp_data[6] =3D err_code & 0xff;
=20=09
write2stack(sdp_con_id, sdp_data, 7);
-
-#undef FNC
}
=20
/* "Support" functions used by the other functions in this file */
@@ -817,7 +785,7 @@
data_struct db_hdl;
struct iovec vec[2];
=20
- D_XMIT("write2stack: writing %d bytes to sdp_con_id %d\n", len, sdp_con_=
id);
+ D_XMIT("Writing %d bytes to sdp_con_id %d", len, sdp_con_id);
=20=20=20
db_hdl.sdp_con_id =3D sdp_con_id;
db_hdl.len =3D len;
@@ -852,7 +820,7 @@
}
else if (len =3D=3D 0)
{
- syslog(LOG_DEBUG, "No data was read\n");
+ syslog(LOG_DEBUG, "No data was read");
}
else
{
@@ -876,7 +844,7 @@
=20=20=20=20=20
select(FD_SETSIZE, &rfd, NULL, NULL, NULL);
=20
- printf(__FUNCTION__", \n");
+ printf(__FUNCTION__ "\n");
=20=20=20=20=20
if (FD_ISSET(clnt_fd, &rfd))
{
@@ -906,7 +874,7 @@
int sdp_srv_sock;
int sdp_clnt_sock;
=20
- syslog(LOG_INFO, "Opening server socket %s\n", name);
+ syslog(LOG_INFO, "Opening server socket %s", name);
=20
/* remove any old socket */
unlink(name);
@@ -925,7 +893,7 @@
=20
while (1)
{
- syslog(LOG_INFO, "SDP Server listens...\n");
+ syslog(LOG_INFO, "SDP Server listens...");
listen(sdp_srv_sock, 5);
=20
client_len =3D sizeof(client_address);
--- sdp_server.c 2001/03/25 09:50:02 1.18
+++ sdp_server.c 2001/03/26 11:28:41 1.19
@@ -51,68 +51,68 @@
#include "sdp_parser.h"
=20
#ifdef BTD_USERSTACK
-#define syslog(x, fmt...) printf(fmt)
+#define syslog(x, fmt...) do { fprintf(stderr, __FILE__ "::"); fprintf(std=
err, fmt); fprintf(stderr, "\n"); } while (0)
#endif
=20
/* Does printouts in all functions called by expat */
-#define DBG_SUBFNC 0
+#define SDP_DEBUG_SUBFNC 0
=20
/* Does debug printouts in functions related to incomming data from the sdp
parts in the kernel */
-#define DBG_SDP_INCOMING 0
+#define SDP_DEBUG_INCOMING 0
=20
/* Other misc functions such as get_values, char2hex etc */
-#define DBG_MISC 0
+#define SDP_DEBUG_MISC 0
=20
/* Debug for the get attribute functions */
-#define DBG_GET_ATTRIBUTES 0
+#define SDP_DEBUG_GET_ATTRIBUTES 0
=20
/* Debug for the get record handle functions */
-#define DBG_GET_RECORD_HDL 0
+#define SDP_DEBUG_GET_RECORD_HDL 0
=20
/* Debug all malloc and free commands */
-#define DBG_MEM 0
+#define SDP_DEBUG_MEM 0
=20
/* Printouts data in hex format */
-#define DBG_PRINT_DATA 0
+#define SDP_DEBUG_PRINT_DATA 0
=20
-#if DBG_SUBFNC
-#define S_FNC(fmt...) syslog(LOG_DEBUG, fmt)
+#if SDP_DEBUG_SUBFNC
+#define S_FNC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define S_FNC(fmt...)
#endif
=20
-#if DBG_SDP_INCOMING
-#define D_REC(fmt...) syslog(LOG_DEBUG, fmt)
+#if SDP_DEBUG_INCOMING
+#define D_REC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_REC(fmt...)
#endif
=20
-#if DBG_MISC
-#define D_MISC(fmt...) syslog(LOG_DEBUG, fmt)
+#if SDP_DEBUG_MISC
+#define D_MISC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_MISC(fmt...)
#endif
=20
-#if DBG_GET_ATTRIBUTES
-#define D_ATTR(fmt...) syslog(LOG_DEBUG, fmt)
+#if SDP_DEBUG_GET_ATTRIBUTES
+#define D_ATTR(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_ATTR(fmt...)
#endif
=20
-#if DBG_GET_RECORD_HDL
-#define D_RHDL(fmt...) syslog(LOG_DEBUG, fmt)
+#if SDP_DEBUG_GET_RECORD_HDL
+#define D_RHDL(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_RHDL(fmt...)
#endif
=20
-#if DBG_MEM
-#define D_MEM(fmt...) syslog(LOG_DEBUG, fmt)
+#if SDP_DEBUG_MEM
+#define D_MEM(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt)
#else
#define D_MEM(fmt...)
#endif
=20
-#if DBG_PRINT_DATA
+#if SDP_DEBUG_PRINT_DATA
#define PRINT_DATA(str, data, len) print_data(str, data, len)
#else
#define PRINT_DATA(str, data, len)
@@ -160,36 +160,27 @@
extern cont_state_struct *cont_state_buf;
=20
void=20
-print_data(const char *message, char *buf, int len)
+print_data(const char *message, const unsigned char *buf, int len)
{=20
- int t, offs;
- char tmp[1024];
+ int t, offs =3D 0;
+ char tmp[100];
=20=20=20
- sprintf(tmp, "\n %s (%d)", message, len);
- offs =3D strlen(tmp);
+ syslog(LOG_DEBUG, "%s (%d):", message, len);
=20=20=20
for (t =3D 0; t < len; t++)=20
{
- if ((t % 16) =3D=3D 0)
+ offs +=3D sprintf(tmp + offs, " 0x%02x", (unsigned int)buf[t]);
+ if (!((t+1) % 8))
{
- if ((offs + 2) > (1024 - 3))
- break;
-
- sprintf(tmp + offs , "\n ");
- offs +=3D 2;
+ syslog(LOG_DEBUG, tmp);
+ offs =3D 0;
}
-=20=20=20=20
- if ((offs + 5) > (1024 - 3))
- break;
-=20=20=20
- sprintf(tmp + offs, "0x%02x ", (unsigned char) buf[t]);
- offs +=3D 5;
-=20=20=20
}
- sprintf(tmp + offs, "\n");
=20
- syslog(LOG_DEBUG, "%s", tmp);
-=20=20
+ if (offs)
+ {
+ syslog(LOG_DEBUG, tmp);
+ }
}
=20
void
@@ -227,7 +218,7 @@
buf =3D XML_GetBuffer(p, BUFFSIZE);
if (buf =3D=3D NULL)
{
- syslog(LOG_ERR, "start_xml_parser: couldn't get a free buffer\n");
+ syslog(LOG_ERR, "start_xml_parser: couldn't get a free buffer");
break;
}
=20
@@ -262,7 +253,7 @@
=20
m_size =3D strlen(char_data) / 2;=20
hex_data =3D (char*) malloc(m_size);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, m_size, (int) =
hex_data);
+ D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, m_size, hex_data=
);
=20
/* FIXME, How will this work when using big endian ? */
for (i =3D 0; i < strlen(char_data) / 2; i++)
@@ -277,7 +268,6 @@
char*
get_values(char *value_string, int value_string_len, int fd)
{
-#define FNC "get_values: "
int value_string_pos =3D 0;
char *tmp_list;
char tmp_len =3D 0;
@@ -289,7 +279,7 @@
i =3D 0;
while (i < value_string_len)
{
- D_MISC(FNC"%s \n",value_string + i);
+ D_MISC("%s", value_string + i);
i +=3D strlen(value_string + i) + 1;
}
=20=20=20
@@ -299,8 +289,7 @@
}
=20=20=20
tmp_list =3D (char*) malloc(256);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, 256, (int) tmp=
_list);
-=20=20
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, tmp_list);
=20=20=20
/* While we have not reached the end of the string */
while (value_string_pos < value_string_len)
@@ -317,17 +306,17 @@
{
int j;
=20
- i =3D (int) strtol(value_string + value_string_pos +
- strlen(S_DES_HDR), NULL, 16);
+ i =3D (int) strtol(value_string + value_string_pos + strlen(S_DES_=
HDR),
+ NULL, 16);
=20
/* Now we found a data element sequens header inside another
data element sequense */
if (des_pos[i])
{
sprintf(c_des_len[i], "%02x", des_len[i]);
- D_MISC(FNC"c_des_len[%d]: %s\n", i, c_des_len[i]);
+ D_MISC("c_des_len[%d]: %s", i, c_des_len[i]);
strncpy(des_pos[i], c_des_len[i], 2);
- D_MISC(FNC"des_pos[%d]: %s\n", i, des_pos[i]);
+ D_MISC("des_pos[%d]: %s", i, des_pos[i]);
}
des_pos[i] =3D tmp_list + tmp_len - 2;
des_len[i] =3D 0;
@@ -353,8 +342,8 @@
=20=20=20=20=20=20=20
if (tmp_code =3D=3D NULL)
{
- D_MISC(FNC"Didn't find the hex code for: %s\n", value_string
- + value_string_pos);
+ D_MISC("Didn't find the hex code for: %s",
+ value_string + value_string_pos);
}
else
{
@@ -368,12 +357,12 @@
des_len[1] +=3D tmp / 2;
des_len[0] +=3D tmp / 2;
=20
- D_MISC(FNC"des_len[1]: %d\n", des_len[1]);
- D_MISC(FNC"Found %s\n", tmp_code);
+ D_MISC("des_len[1]: %d", des_len[1]);
+ D_MISC("Found %s", tmp_code);
=20
/* since get_from_xml allocates space for the reurn paramterer we
have to do free here */
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) tmp_code);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp_code);
free(tmp_code);
}
}
@@ -388,42 +377,34 @@
sprintf(c_des_len[i], "%02x", des_len[i]);
strncpy(des_pos[i], c_des_len[i], 2);
=20
- D_MISC(FNC"%s\n", des_pos[i]);
- D_MISC(FNC"c_des_len[%d]: %s\n",i, c_des_len[i]);
+ D_MISC("%s", des_pos[i]);
+ D_MISC("c_des_len[%d]: %s",i, c_des_len[i]);
}
}
=20
- D_MISC(FNC"return_list %s\n", tmp_list);
+ D_MISC("return_list %s", tmp_list);
=20
return tmp_list;
-#undef FNC
}
=20
void set_sdp_hdr(unsigned char *hdr, unsigned char pkt_type,
unsigned short trans_id, unsigned short len)
{
-#define FCN "set_sdp_hdr: "
-
hdr[0] =3D pkt_type;
hdr[1] =3D SHORT2CHAR_MS(trans_id);
hdr[2] =3D SHORT2CHAR_LS(trans_id);
hdr[3] =3D SHORT2CHAR_MS(len);
hdr[4] =3D SHORT2CHAR_LS(len);
-=09
-#undef FNC
}
=20
unsigned int
get_record_handle(unsigned short service_class, int fd)
{
-#define FNC "get_record_handle: "
-=20=20
int record_handle =3D NO_REC_HDL;
char *service_class_name =3D NULL;
char *service_class_id =3D NULL;
char tmp[12];
=20
-=20=20
/* Before we can get the recordhandle we have to find the name of the
service class, so we can search for it in the database. When we search
the service class id, have to be converted to characters. All service
@@ -435,7 +416,7 @@
/* If we didn't find the service class we return here */
if (service_class_name =3D=3D NULL)
{
- D_RHDL(FNC"Didn't find ServiceClass name for uuid 0x%04x\n",service_cl=
ass);
+ D_RHDL("Didn't find ServiceClass name for uuid 0x%04x", service_class);
return NO_REC_HDL;
}
=20=20=20
@@ -445,52 +426,48 @@
service_class_id =3D get_from_xml(fd, service_class_name,
"ServiceRecordHandle", NULL);
=20
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) service_class_name);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, service_class_name);
free(service_class_name);
=20=20=20
/* If we found the record handle we convert it to an unsigned int */
if (service_class_id !=3D NULL)
{
- D_RHDL(FNC"Found %s\n", service_class_id);
+ D_RHDL("Found %s", service_class_id);
record_handle =3D (unsigned int) strtol(service_class_id, NULL, 16);
- D_RHDL(FNC"Record handle converted to int 0x%08x\n", record_handle);
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) service_class_id);
+ D_RHDL("Record handle converted to int 0x%08x", record_handle);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, service_class_id);
free(service_class_id);
}
=20
return record_handle;
-#undef FNC
}
=20
void
get_more_rec_hdl_start(void *data, const char *el, const char **attr)
{
-#define FNC "get_more_rec_hdl_start: "
-
unsigned int *tmp;
rec_hdl_search_struct *s_hdl =3D (rec_hdl_search_struct*) data;
=20
if (attr[0] && strcmp(attr[0], "ServiceRecordHandle") =3D=3D 0)
{
-=20=20=20=20
- S_FNC(FNC"Found Record Handle %s\n", attr[1]);
+ S_FNC("Found Record Handle %s", attr[1]);
s_hdl->tmp_hdl =3D (unsigned int)strtol(attr[1], NULL, 16);
- S_FNC(FNC"Found Record Handle 0x%08x\n", s_hdl->tmp_hdl);
+ S_FNC("Found Record Handle 0x%08x", s_hdl->tmp_hdl);
}
if ((s_hdl->tmp_hdl) && (strcmp(el, s_hdl->uuid) =3D=3D 0))
{
if ((s_hdl->hdl_list_len > 0) &&
(s_hdl->tmp_hdl =3D=3D s_hdl->hdl_list[(s_hdl->hdl_list_len / U32_SIZE) -=
1]))
{
- S_FNC(FNC"%s is present in record handle 0x%08x, but already found\n=
",
+ S_FNC("%s is present in record handle 0x%08x, but already found",
s_hdl->uuid, s_hdl->tmp_hdl);
}
else
{
- S_FNC(FNC"%s is present in record handle 0x%08x\n",
+ S_FNC("%s is present in record handle 0x%08x",
s_hdl->uuid, s_hdl->tmp_hdl);
=20=20=20=20=20=20=20
- /* Store the poiter to the allready found record handles, and than if
+ /* Store the poiter to the allready found record handles, and then if
necessary allocate new space for both the old and the new record
handles */
=20=20=20=20=20=20=20
@@ -499,12 +476,12 @@
tmp =3D s_hdl->hdl_list;
s_hdl->block_len =3D s_hdl->hdl_list_len + s_hdl->block_len * 2;
s_hdl->hdl_list =3D (unsigned int*) malloc(s_hdl->block_len);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, s_hdl->block_le=
n, (unsigned int) s_hdl->hdl_list);
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, s_hdl->bloc=
k_len, s_hdl->hdl_list);
=20=09
memcpy(s_hdl->hdl_list, tmp, s_hdl->hdl_list_len);
if (tmp)
{
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) tmp);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp);
free(tmp);
}
}
@@ -513,8 +490,6 @@
s_hdl->hdl_list_len +=3D sizeof(unsigned int);
}
}
-=20=20
-#undef FNC
}
=20
void
@@ -525,8 +500,6 @@
unsigned int*
get_more_rec_hdl(unsigned short service_class, int fd)
{
-#define FNC "get_more_rec_hdl: "
-
rec_hdl_search_struct s_hdl;
char tmp_ch[12];
unsigned int *tmp;
@@ -537,18 +510,18 @@
sprintf(tmp_ch, "0x%04x", service_class);
s_hdl.uuid =3D get_from_xml(fd, "Protocols", NULL, tmp_ch);=20
=20=20=20=20=20
- /* If we didn't find the service class among the protocols we look in it
+ /* If we didn't find the service class among the protocols we look for it
among the ServiceClasses */
if (s_hdl.uuid =3D=3D NULL)
{
- D_RHDL(FNC"Didn't find Protocol name for uuid 0x%04x among the protoco=
ls\n"
- ,service_class);
+ D_RHDL("Didn't find Protocol name for uuid 0x%04x among the protocols",
+ service_class);
s_hdl.uuid =3D get_from_xml(fd, "ServiceClasses", NULL, tmp_ch);=20
=20
/* If we still didn't find the sevice class, we return NULL */
if (s_hdl.uuid =3D=3D NULL)
{
- D_RHDL(FNC"Didn't find Protocol name for uuid 0x%04x\n",service_clas=
s);
+ D_RHDL("Didn't find Protocol name for uuid 0x%04x", service_class);
return NULL;
}
}
@@ -572,12 +545,12 @@
s_hdl.block_len +=3D 1;
=20=20=20=20=20
s_hdl.hdl_list =3D (unsigned int*) malloc(tmp_len);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, tmp_len, (in=
t) s_hdl.hdl_list);
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, tmp_len, s_hdl.=
hdl_list);
=20=20=20=20=20
memcpy(s_hdl.hdl_list, tmp, s_hdl.hdl_list_len);
if (tmp)
{
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) tmp);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp);
free(tmp);
}
}
@@ -585,26 +558,22 @@
s_hdl.hdl_list_len +=3D sizeof(unsigned int);
=20=20=20
return s_hdl.hdl_list;
-=20=20
-#undef FNC
}
=20
char*
get_attribute_range(int fd, unsigned int record_handle,
unsigned int attr_id_code)
{
-#define FNC "get_attribute_range: "
-=20=20
int *attr_lst, i =3D 1, pos =3D 0;
char *tmp_ptr;
char *return_sequence;
=20
/* FIXME: But for now 256 bytes will do */
return_sequence =3D (char*) malloc(256);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, 256, (int) ret=
urn_sequence);
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, return_seque=
nce);
=20=20=20
=20=20=20
- D_ATTR(FNC" A range of attributes was requested 0x%04x - 0x%04x\n",
+ D_ATTR("A range of attributes was requested 0x%04x - 0x%04x",
(attr_id_code >> 16), (attr_id_code & 0xffff));
=20=20=20
/* Lists all attributes registerd in the database */
@@ -619,12 +588,12 @@
{
i++;
}
- D_ATTR(FNC"attr_lst[0]: %d, attr_id_code: 0x%04x\n",
+ D_ATTR("attr_lst[0]: %d, attr_id_code: 0x%04x",
attr_lst[0], attr_id_code);
=20=20=20
while ((i < attr_lst[0]) && (attr_lst[i] <=3D (attr_id_code & 0xffff)))
{
- D_REC(FNC"attr_lst[%d]: 0x%04x\n", i, attr_lst[i]);
+ D_REC("attr_lst[%d]: 0x%04x", i, attr_lst[i]);
/* we mask the attribute her so we don't by misstake send a range as
input */
tmp_ptr =3D get_attribute_list(fd, record_handle, attr_lst[i] & 0xffff=
);
@@ -633,17 +602,17 @@
{
memcpy(return_sequence + pos, tmp_ptr + 2, tmp_ptr[1]);
pos +=3D tmp_ptr[1];
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) tmp_ptr);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp_ptr);
free(tmp_ptr);
}
i++;
}
=20=20=20
return_sequence[1] =3D pos - 2;
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) attr_lst);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, attr_lst);
free(attr_lst);
=20
- PRINT_DATA(FNC"return_sequence\n", return_sequence, return_sequence[1] +=
2);
+ PRINT_DATA(__FUNCTION__ ": return_sequence", return_sequence, return_seq=
uence[1] + 2);
=20=20=20
if (return_sequence[1] =3D=3D 0)
{
@@ -654,8 +623,6 @@
{
return return_sequence;
}
-=20=20
-#undef FNC
}
=20
void init_attribute_search_struct(sdp_attribute_search *search_struct)
@@ -679,7 +646,6 @@
get_attribute_list(int fd, unsigned int record_handle,
unsigned short attr_id_code)
{
-#define FNC "get_attribute_list: "
#define SEQ_LEN 256
=20
XML_Parser p;
@@ -692,7 +658,7 @@
=20
init_attribute_search_struct(&search_struct);
=20=20=20
- D_ATTR(FNC" Searching for attribute 0x%04x for record handle 0x%08x\n",
+ D_ATTR("Searching for attribute 0x%04x for record handle 0x%08x",
attr_id_code, record_handle);
=20=20=20
search_struct.attribute_id =3D attr_id_code;
@@ -701,27 +667,26 @@
=20
if (search_struct.attribute_name =3D=3D NULL)
{
- fprintf(stderr, FNC"Didn't find service attribute id name for uuid 0x%=
04x\n",
- attr_id_code);
+ fprintf(stderr, __FUNCTION__ ": Didn't find service attribute id name =
for uuid 0x%04x\n", attr_id_code);
return NULL;
}
=20=20=20
- D_ATTR(FNC"Found %s\n", search_struct.attribute_name);
+ D_ATTR("Found %s", search_struct.attribute_name);
=20
sprintf(tmp, "0x%08x", record_handle);
search_struct.service_class =3D get_from_xml(fd, NULL, "ServiceRecordHan=
dle", tmp);
=20=20=20
if (search_struct.service_class =3D=3D NULL)
{
- fprintf(stderr, FNC"Didn't find service class name for RecordHandle 0x=
%08x\n", record_handle);
+ fprintf(stderr, __FUNCTION__ ": Didn't find service class name for Rec=
ordHandle 0x%08x\n", record_handle);
=20
set_err(SDP_INVALID_SERVICE_RECORD_HANDLE);
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) search_struct.attribu=
te_name);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.attribute_name);
free(search_struct.attribute_name);
return NULL;
}
=20=20=20
- D_ATTR(FNC"Found %s\n", search_struct.service_class);
+ D_ATTR("Found %s", search_struct.service_class);
=20
p =3D XML_ParserCreate(NULL);
XML_SetElementHandler(p, get_attribute_list_start, get_attribute_list_en=
d);
@@ -734,7 +699,7 @@
=20
if (search_struct.attrlist_index =3D=3D 0)
{
- D_ATTR(FNC" Didn't find the attribute values for the attribute %s\n",
+ D_ATTR("Didn't find the attribute values for the attribute %s",
search_struct.attribute_name);
return NULL;
}
@@ -745,32 +710,29 @@
hex_tmp =3D char2hex(char_tmp);
=20
return_sequence =3D (char*) malloc(len + 2);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, len + 2, (int)=
return_sequence);
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, len + 2, return_s=
equence);
=20=20=20
return_sequence[0] =3D 0x35;
return_sequence[1] =3D len;
memcpy(return_sequence + 2, hex_tmp, len);
=20=20=20
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) char_tmp);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, char_tmp);
free(char_tmp);
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) hex_tmp);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, hex_tmp);
free(hex_tmp);
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) search_struct.attribute=
_name);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.attribute_name);
free(search_struct.attribute_name);
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) search_struct.service_c=
lass);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.service_class);
free(search_struct.service_class);
=20
- PRINT_DATA(FNC"return value\n", return_sequence, len + 2);
+ PRINT_DATA(__FUNCTION__ ": return value", return_sequence, len + 2);
=20
return return_sequence;
-=20=20
-#undef FNC
}
=20
void
get_attribute_list_start(void *data, const char *el, const char **attr)
{
-#define FNC "get_attribute_list_start: "
int i;
sdp_attribute_search *search_struct;
=20
@@ -780,7 +742,7 @@
service_class_found parameter to TRUE */
if (strcmp(el, search_struct->service_class) =3D=3D 0)
{
- S_FNC(FNC"Found service class %s\n", el);
+ S_FNC("Found service class %s", el);
search_struct->service_class_found +=3D 1;
}
if (search_struct->service_class_found)
@@ -791,7 +753,7 @@
{
search_struct->attribute_name_found =3D 1;
=20=20=20=20=20=20=20
- S_FNC(FNC"Found attribute name %s\n", el);
+ S_FNC("Found attribute name %s", el);
=20
/* We then inserts the attribute id code of the attribute type we ha=
ve
found */
@@ -806,15 +768,15 @@
if (strcmp(attr[i], "NbrOfEntities") =3D=3D 0)
{
search_struct->attr2get =3D atoi(attr[i + 1]);
- S_FNC(FNC"attr2get: %d\n", atoi(attr[i + 1]));
+ S_FNC("attr2get: %d", atoi(attr[i + 1]));
/* Set the data element sequence header */
strcpy(search_struct->attrlist + search_struct->attrlist_index, S_DES_H=
DR0);
search_struct->attrlist_index +=3D strlen(S_DES_HDR0) + 1;
}
/* Otherwise the wole attribute may be stored as a data element
sequence */
- else if (attr[i] && attr[i + 1] && (strcmp(attr[i], "type") =3D=3D 0)
- && (strcmp(attr[i + 1], "DES") =3D=3D 0))
+ else if (attr[i] && attr[i + 1] && (strcmp(attr[i], "type") =3D=3D=
0) &&
+ (strcmp(attr[i + 1], "DES") =3D=3D 0))
{
/* Set the data element sequence header */
strcpy(search_struct->attrlist + search_struct->attrlist_index, S_DES_H=
DR1);
@@ -863,7 +825,6 @@
the function get_values */
}
}
-#undef FNC
}
=20
=20
@@ -878,13 +839,13 @@
can se whether it was the last end tag for the service class or not*/
if (strcmp(el, search_hdl->service_class) =3D=3D 0)
{
- S_FNC("get_attribute_list_end: Found %s\n", el);
+ S_FNC("Found %s", el);
search_hdl->service_class_found -=3D 1;
}
/* If we have found the attribute name end tag, there are no more attrib=
utes
to find */
- else if ((strcmp(el, search_hdl->attribute_name) =3D=3D 0)
- && (search_hdl->service_class_found))
+ else if ((strcmp(el, search_hdl->attribute_name) =3D=3D 0) &&
+ (search_hdl->service_class_found))
{
search_hdl->attribute_name_found =3D 0;
}
@@ -904,7 +865,6 @@
void
get_attribute_char_data(void *userData, const XML_Char *s, int len)
{
-#define FNC "get_attribute_char_data: "
sdp_attribute_search *search_hdl =3D (sdp_attribute_search*) userData;
int i =3D 0;
=20
@@ -947,7 +907,6 @@
strncpy(search_hdl->attrlist + search_hdl->attrlist_index, "\0", 1);
search_hdl->attrlist_index +=3D 1;
}
-#undef FNC
}
=20
/* This function search the xml file for the one of tag, attr or val that =
is
@@ -957,7 +916,6 @@
char*
get_from_xml(int fd, char *tag, char *attr, unsigned char *val)
{
-#define FNC "get_from_xml: "
#define TAG 0
#define ATTR 1
#define VAL 2
@@ -976,7 +934,7 @@
=20=20=20
if (!tag)
{
- S_FNC(FNC"Looking for tag\n");
+ S_FNC("Looking for tag");
set_value =3D TAG;
}
=20
@@ -984,10 +942,10 @@
{=20=20=20=20
if (set_value !=3D -1)
{
- fprintf(stderr, FNC"Error more the one attribute =3D=3D NULL\n");
+ fprintf(stderr, __FUNCTION__ ": Error more the one attribute =3D=3D =
NULL\n");
return NULL;
}
- S_FNC(FNC"Looking for attribute\n");
+ S_FNC("Looking for attribute");
set_value =3D ATTR;
}
=20=20=20
@@ -995,10 +953,10 @@
{
if (set_value !=3D -1)
{
- fprintf(stderr, FNC"Error more the one attribute =3D=3D NULL\n");
+ fprintf(stderr, __FUNCTION__ ": Error more the one attribute =3D=3D =
NULL\n");
return NULL;
}
- S_FNC(FNC"Looking for value\n");
+ S_FNC("Looking for value");
set_value =3D VAL;
}
=20=20=20
@@ -1024,7 +982,6 @@
#undef TAG
#undef ATTR
#undef VAl
-#undef FNC
}
=20
=20
@@ -1039,15 +996,15 @@
{
if (strcmp(el, search_hdl->search_name) =3D=3D 0)
{
- S_FNC("get_start: Found %s\n", el);
+ S_FNC("Found %s", el);
for (i =3D 0; attr[i]; i +=3D 2)
{
if (strcmp(attr[i + 1], search_hdl->search_val) =3D=3D 0)
{
- S_FNC("get_start: Found %s\n", attr[i]);
+ S_FNC("Found %s", attr[i]);
m_size =3D strlen(attr[i] + 1);
search_hdl->search_attr =3D (char*) malloc(m_size);
- D_MEM("---> malloc%d % d bytes at 0x%08x\n", malloc_dbg++, m_size, (int=
) search_hdl->search_attr);
+ D_MEM("---> malloc%d % d bytes at 0x%8p", malloc_dbg++, m_size, =
search_hdl->search_attr);
strcpy(search_hdl->search_attr, attr[i]);
return;
}
@@ -1058,15 +1015,15 @@
{
if (strcmp(el, search_hdl->search_name) =3D=3D 0)
{
- S_FNC("get_start: Found %s\n", el);
+ S_FNC("Found %s", el);
for (i =3D 0; attr[i]; i +=3D 2)
{
if (strcmp(attr[i], search_hdl->search_attr) =3D=3D 0)
{
- S_FNC("get_start: Found %s\n", attr[i + 1]);
+ S_FNC("Found %s", attr[i + 1]);
m_size =3D strlen(attr[i + 1] + 1);
search_hdl->search_val =3D (char*) malloc(m_size);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, m_size, (int)=
search_hdl->search_val);
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, s=
earch_hdl->search_val);
strcpy(search_hdl->search_val, attr[i + 1]);
return;
}
@@ -1077,12 +1034,12 @@
{
for (i =3D 0; attr[i]; i +=3D 2)
{
- if ((strcmp(search_hdl->search_attr, attr[i]) =3D=3D 0)
- && (strcmp(search_hdl->search_val, attr[i + 1]) =3D=3D 0))
+ if ((strcmp(search_hdl->search_attr, attr[i]) =3D=3D 0) &&
+ (strcmp(search_hdl->search_val, attr[i + 1]) =3D=3D 0))
{
m_size =3D strlen(el) + 1;
search_hdl->search_name =3D (char*) malloc(m_size);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, m_size, (int) s=
earch_hdl->search_name);
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, sea=
rch_hdl->search_name);
strcpy(search_hdl->search_name, el);
return;
}
@@ -1119,7 +1076,7 @@
=20
for (i =3D 1; i <=3D attr_lst[0]; i++)
{
- D_ATTR("Before free Attribute %d: 0x%04x\n", i , attr_lst[i]);
+ D_ATTR("Before free Attribute %d: 0x%04x", i , attr_lst[i]);
}
=20
XML_ParserFree(p);
@@ -1127,13 +1084,13 @@
/* If we didn't find the service class we return here */
if (search_hdl.search_val =3D=3D NULL)
{
- D_ATTR("get_all_attributes: Didn't find anything\n");
+ D_ATTR("Didn't find anything");
return 0;
}
=20
for (i =3D 1; i <=3D attr_lst[0]; i++)
{
- D_ATTR("Attribute %d: 0x%04x\n", i , attr_lst[i]);
+ D_ATTR("Attribute %d: 0x%04x", i , attr_lst[i]);
}
=20=20=20=20=20
return attr_lst;
@@ -1148,25 +1105,25 @@
=20=20=20
if (strncmp(el, search_hdl->search_name, strlen(search_hdl->search_name)=
) =3D=3D0)
{
- S_FNC("get_all_start: Found %s\n", el);
+ S_FNC("Found %s", el);
attr_cnt =3D XML_GetSpecifiedAttributeCount((XML_Parser*) data);
/* Since attr_cnt is the count of both the attibutes and the attribute
values, we have to divide it by 2 */
attr_cnt /=3D 2;
=20=20=20=20=20
- S_FNC("get_all_start: %d attributes found\n", attr_cnt);
+ S_FNC("%d attributes found", attr_cnt);
/* Allocate space for all the attribute UUIDs plus the attribute count
in the search_output pointer, */
m_size =3D attr_cnt * 4 + 4;
search_hdl->search_val =3D (char*) malloc(m_size);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, m_size, (int=
)search_hdl->search_val);
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, search_=
hdl->search_val);
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
memcpy(search_hdl->search_val + 4 +(i * 2), &tmp ,4);
- S_FNC(__FUNCTION__", Attribute %d found \n", tmp);
+ S_FNC("Attribute %d found", tmp);
}=20
}
}
@@ -1177,38 +1134,32 @@
=20
void browse_database()
{
-
-
}
=20
void browse_database_start(void *data, const char *el, const char **attr)
{
-=09
}
=20
void browse_database_end(void *data, const char *el)
{
-
}
=20
void
handle_query(database_query_struct *db_hdl)
{
-#define FNC "handle_query: "
-
switch (db_hdl->pkt_type) {
case SDP_SERVICESEARCH_REQ:
- D_REC(FNC" Got SDP_SERVICESEARCH_REQ\n");
+ D_REC("Got SDP_SERVICESEARCH_REQ");
handle_service_search_req((service_search_struct*) db_hdl);
break;
=20=20=20
case SDP_SERVICEATTR_REQ:
- D_REC(FNC"Got SDP_SERVICEATTR_REQ\n");
+ D_REC("Got SDP_SERVICEATTR_REQ");
handle_service_attr_req((service_attr_struct*) db_hdl);
break;
=20=20=20
case SDP_SERVICESEARCHATTR_REQ:
- D_REC(FNC"Got SDP_SERVICESEARCHATTR_REQ\n");
+ D_REC("Got SDP_SERVICESEARCHATTR_REQ");
handle_service_search_attr_req((service_search_attr_struct*) db_hdl);
break;
=20=20=20=20=20
@@ -1216,8 +1167,6 @@
fprintf(stderr, "Unrecognised packet 0x%02x\n", db_hdl->pkt_type);
break;
}
-
-#undef FNC
}
=20
/* FIXME: Add features to handle continuation states and multiple service
@@ -1226,8 +1175,6 @@
void=20
handle_service_search_req(service_search_struct *db_hdl)
{
-#define FNC "handle_service_search_req: "
-
unsigned char rsp_pkt[256];
int rsp_pkt_len;
unsigned int rec_hdl, rec_hdl_cnt =3D 0;
@@ -1243,13 +1190,13 @@
=20
rec_hdl_list =3D get_more_rec_hdl(db_hdl->service_class_list[0], xml_fd);
=20=20=20
- D_REC(FNC"Got Record handle: 0x%08x\n", rec_hdl);
+ D_REC("Got Record handle: 0x%08x", rec_hdl);
if (rec_hdl_list)
{
i =3D 0;
while (rec_hdl_list[i] !=3D NO_REC_HDL)
{
- D_REC(FNC"Got Record handle: 0x%08x\n", rec_hdl_list[i]);
+ 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;
@@ -1291,7 +1238,7 @@
rsp_pkt[rsp_pkt_len + 3] =3D rec_hdl_list[i] & 0xff;
rsp_pkt_len +=3D 4;
}
- D_MEM("<--- free%d 0x%08x\n", malloc_dbg--, (unsigned int)rec_hdl_list=
);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list);
free(rec_hdl_list);
}
=20=20=20
@@ -1301,14 +1248,11 @@
rsp_pkt_len =3D set_cont_state_search(rsp_pkt, rsp_pkt_len, db_hdl->max_=
rec_cnt);
=20
write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20
-#undef FNC
}
=20
void=20
handle_service_attr_req(service_attr_struct *db_hdl)
{
-#define FNC "handle_service_attr_req: "
-
unsigned char rsp_pkt[256];
int rsp_pkt_len, i, des_len_pos;
unsigned char *tmp_ptr;
@@ -1335,7 +1279,7 @@
memcpy(rsp_pkt + rsp_pkt_len, tmp_ptr + 2, tmp_ptr[1]);
rsp_pkt_len +=3D tmp_ptr[1] ;
=20=20=20=20=20=20=20
- D_MEM("<--- free %d 0x%08x\n", malloc_dbg--, (int) tmp_ptr);
+ D_MEM("<--- free %d 0x%8p", --malloc_dbg, tmp_ptr);
free(tmp_ptr);
}
else
@@ -1365,13 +1309,11 @@
rsp_pkt_len =3D set_cont_state_attr(rsp_pkt, rsp_pkt_len,db_hdl->max_att=
r_byte_cnt);
=20
write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20
-#undef FNC
}
=20
void=20
handle_service_search_attr_req(service_search_attr_struct *db_hdl)
{
-#define FNC "handle_service_search_attr_req: "
unsigned char *tmp_ptr;
unsigned int rec_hdl;
unsigned int *rec_hdl_list;
@@ -1381,7 +1323,7 @@
=20
rec_hdl =3D get_record_handle(db_hdl->service_class_list[0], xml_fd);
=20
- D_REC(FNC"Got Record handle: 0x%08x\n", rec_hdl);
+ D_REC("Got Record handle: 0x%08x", rec_hdl);
=20=20=20
rec_hdl_list =3D get_more_rec_hdl(db_hdl->service_class_list[0], xml_fd);
=20=20=20
@@ -1392,12 +1334,12 @@
{
if (rec_hdl_list[i] !=3D rec_hdl)
{
- D_REC(FNC"Got Record handle list %d: 0x%08x\n", i, rec_hdl_list[i]);
+ D_REC("Got Record handle list %d: 0x%08x", i, rec_hdl_list[i]);
j++;
}
else
{
- D_REC(FNC"Dupplicated record handle %d: 0x%08x\n", i, rec_hdl_list[i]);
+ D_REC("Dupplicated record handle %d: 0x%08x", i, rec_hdl_list[i]);
}
}
rec_hdl_cnt +=3D j;
@@ -1430,13 +1372,13 @@
}
if (tmp_ptr)
{
- printf(FNC"Copying %d bytes to rsp_pkt\n", tmp_ptr[1]);
+ printf(__FUNCTION__ ": Copying %d bytes to rsp_pkt\n", tmp_ptr[1]);
memcpy(rsp_pkt + rsp_pkt_len + tmp_len, tmp_ptr + 2, tmp_ptr[1]);
tmp_len +=3D tmp_ptr[1];
=20=20=20=20=20=20=20=20=20=20=20
- printf(FNC"list_len:%d\n", tmp_len);
+ printf(__FUNCTION__ ": list_len: %d\n", tmp_len);
=20=20=20=20=20=20=20=20=20
- D_MEM("<--- free tmp_ptr 0x%08x\n",malloc_dbg--, (unsigned int) tm=
p_ptr);
+ D_MEM("<--- free%d tmp_ptr 0x%8p", --malloc_dbg, tmp_ptr);
free(tmp_ptr);
}
}
@@ -1449,7 +1391,7 @@
}
if (rec_hdl_list !=3D &rec_hdl)
{
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (unsigned int) rec_hdl_list=
);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list);
free(rec_hdl_list);
}
=20
@@ -1471,8 +1413,6 @@
=20=20=20
/* FIXME: Add features to handle continuation state packets */
write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20
-=20=20
-#undef FNC=09
}
=20
int
@@ -1485,7 +1425,7 @@
=20
if (cur_rec_cnt > max_rec_cnt)
{
- S_FNC(__FUNCTION__", Setting cont state, cur_rec_cnt:%d, max_rec_cnt:%=
d\n",
+ S_FNC("Setting cont state, cur_rec_cnt:%d, max_rec_cnt:%d",
cur_rec_cnt, max_rec_cnt);
=20
pkt[5] =3D SHORT2CHAR_MS(max_rec_cnt);
@@ -1494,7 +1434,7 @@
pkt[7] =3D SHORT2CHAR_MS(max_rec_cnt);
pkt[8] =3D SHORT2CHAR_LS(max_rec_cnt);
=20=20=20=20=20
- /* There are cnt_len byte to much to fit the data in one packet */
+ /* There are cnt_len byte too much to fit the data in one packet */
cnt_len =3D (cur_rec_cnt - max_rec_cnt) * 4;
=20=20=20=20=20
/* The packet can't be longer than this, excluding the continuation st=
ate
@@ -1502,10 +1442,10 @@
len -=3D cnt_len;
=20=20=20=20=20
cont_state_buf =3D (cont_state_struct*) malloc(sizeof(cont_state_struc=
t) + cnt_len);
- D_MEM("---> malloc%d %d bytes at %p\n", malloc_dbg++, sizeof(cont_stat=
e_struct) + cnt_len, cont_state_buf);
+ 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("set_cont_state_attr: PDU:0x%02x\n", pkt[0]);
+ D_MISC("PDU: 0x%02x", pkt[0]);
=20=20=20=20=20
cont_state_buf->len =3D cnt_len;
memcpy(cont_state_buf->data, pkt + len, cnt_len);
@@ -1540,25 +1480,27 @@
=20=20=20
cur_attr_cnt =3D CHAR2INT16(pkt[5], pkt[6]);
=20
- S_FNC(__FUNCTION__", len %d, max_attr_len %d, cur_attr_cnt %d\n", len, m=
ax_attr_len, cur_attr_cnt);
+ S_FNC("len %d, max_attr_len %d, cur_attr_cnt %d", len, max_attr_len, cur=
_attr_cnt);
=20
- PRINT_DATA("set_cont_state_attr", pkt, len);
+ PRINT_DATA(__FUNCTION__, pkt, len);
=20
if (max_attr_len < cur_attr_cnt)
{
- S_FNC("set_cont_state_attr: max_attr_len:%d, cur_attr_cnt:%d and packe=
t length:%d\n", max_attr_len, cur_attr_cnt, len);
+ S_FNC("max_attr_len:%d, cur_attr_cnt:%d and packet length:%d", max_att=
r_len, cur_attr_cnt, len);
=20=20=20=20=20
/* There are cont_len byte to much to fit the data in one packet */
cont_len =3D cur_attr_cnt - max_attr_len;
+
/* The packet can't be longer than this, excluding the continuation st=
ate
bytes */
len -=3D cont_len;
=20=20=20=20
cont_state_buf =3D (cont_state_struct*) malloc(sizeof(cont_state_struc=
t) + cont_len);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, sizeof(cont_=
state_struct) + cont_len , (unsigned int)cont_state_buf);
+ 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("set_cont_state_attr: PDU:0x%02x\n", pkt[0]);
+ D_MISC("PDU: 0x%02x", pkt[0]);
+
cont_state_buf->len =3D cont_len;
memcpy(cont_state_buf->data, pkt + len, cont_len);
=20
@@ -1572,14 +1514,14 @@
}
else
{
- S_FNC(__FUNCTION__", No continuation State set\n");
+ S_FNC("No continuation State set");
pkt[len] =3D 0;
len +=3D 1;
}
=20=20=20
/* Change the length field */
=20
- S_FNC(__FUNCTION__", Changing length field\n");
+ S_FNC("Changing length field");
pkt[3] =3D SHORT2CHAR_MS(len- SDP_HDR_SIZE);
pkt[4] =3D SHORT2CHAR_LS(len -SDP_HDR_SIZE);
=20=20=20
@@ -1600,12 +1542,12 @@
{
if ((max_rec_cnt * 4) >=3D cont_state_buf->len)
{
- /* Allocate space for the SDP header the attribute byte count field,
- the attribytes and the continuation state field */
+ /* Allocate space for the SDP header, the attribute byte count field,
+ the attributes and the continuation state field */
send_len =3D SDP_HDR_SIZE + 2 + 2 + cont_state_buf->len + 1;
=20=20=20=20=20=20=20
send_buf =3D (unsigned char*) malloc(send_len);
- D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, send_len, =
(unsigned int) send_buf);
+ D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, send_len, sen=
d_buf);
=20
set_sdp_hdr(send_buf, cont_state_buf->pdu, trans_id, send_len - SDP_=
HDR_SIZE);
=20
@@ -1624,13 +1566,12 @@
/* Send the whole buffer */
write2stack(sdp_con_id, send_buf, send_len);
=20
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (unsigned int) cont_state=
_buf);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, cont_state_buf);
free(cont_state_buf);
cont_state_buf =3D NULL;
=20=20=20=20=20=20=20
- D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (unsigned int) send_buf);
+ D_MEM("<--- free%d 0x%8p", --malloc_dbg, send_buf);
free(send_bu...
[truncated message content] |