- Timestamp:
- Jun 11, 2008 11:18:04 AM (16 years ago)
- Location:
- pjproject/trunk/pjsip/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_msg.c
r1954 r2005 1132 1132 1133 1133 if (hdr->q1000) { 1134 unsigned frac; 1135 1134 1136 if (buf+19 >= endbuf) 1135 1137 return -1; … … 1142 1144 printed = pj_utoa(hdr->q1000/1000, buf+3); 1143 1145 buf += printed + 3; 1144 *buf++ = '.'; 1145 printed = pj_utoa(hdr->q1000 % 1000, buf); 1146 buf += printed; 1146 frac = hdr->q1000 % 1000; 1147 if (frac != 0) { 1148 *buf++ = '.'; 1149 if ((frac % 100)==0) frac /= 100; 1150 if ((frac % 10)==0) frac /= 10; 1151 printed = pj_utoa(frac, buf); 1152 buf += printed; 1153 } 1147 1154 } 1148 1155 -
pjproject/trunk/pjsip/src/pjsip/sip_parser.c
r1957 r2005 1641 1641 char *dot_pos = (char*) pj_memchr(pvalue.ptr, '.', pvalue.slen); 1642 1642 if (!dot_pos) { 1643 hdr->q1000 = pj_strtoul(&pvalue) ;1643 hdr->q1000 = pj_strtoul(&pvalue) * 1000; 1644 1644 } else { 1645 pj_str_t tmp = pvalue; 1646 1647 tmp.slen = dot_pos - pvalue.ptr; 1648 hdr->q1000 = pj_strtoul(&tmp) * 1000; 1649 1645 1650 pvalue.slen = (pvalue.ptr+pvalue.slen) - (dot_pos+1); 1646 1651 pvalue.ptr = dot_pos + 1; 1647 hdr->q1000 = pj_strtoul_mindigit(&pvalue, 3);1652 hdr->q1000 += pj_strtoul_mindigit(&pvalue, 3); 1648 1653 } 1649 1654 } else if (!parser_stricmp(pname, pconst.pjsip_EXPIRES_STR) && pvalue.slen) { -
pjproject/trunk/pjsip/src/test-pjsip/msg_test.c
r1957 r2005 790 790 static int hdr_test_contact0(pjsip_hdr *h); 791 791 static int hdr_test_contact1(pjsip_hdr *h); 792 static int hdr_test_contact_q0(pjsip_hdr *h); 793 static int hdr_test_contact_q1(pjsip_hdr *h); 794 static int hdr_test_contact_q2(pjsip_hdr *h); 795 static int hdr_test_contact_q3(pjsip_hdr *h); 796 static int hdr_test_contact_q4(pjsip_hdr *h); 792 797 static int hdr_test_content_length(pjsip_hdr *h); 793 798 static int hdr_test_content_type(pjsip_hdr *h); … … 898 903 899 904 { 905 /* q=0 parameter in Contact header */ 906 "Contact", "m", 907 NAME_ADDR ";q=0", 908 &hdr_test_contact_q0, 909 HDR_FLAG_DONT_PRINT 910 }, 911 912 { 913 /* q=0.5 parameter in Contact header */ 914 "Contact", "m", 915 NAME_ADDR ";q=0.5", 916 &hdr_test_contact_q1 917 }, 918 919 { 920 /* q=1 parameter in Contact header */ 921 "Contact", "m", 922 NAME_ADDR ";q=1", 923 &hdr_test_contact_q2 924 }, 925 926 { 927 /* q=1.0 parameter in Contact header */ 928 "Contact", "m", 929 NAME_ADDR ";q=1.0", 930 &hdr_test_contact_q3, 931 HDR_FLAG_DONT_PRINT 932 }, 933 934 { 935 /* q=1.1 parameter in Contact header */ 936 "Contact", "m", 937 NAME_ADDR ";q=1.15", 938 &hdr_test_contact_q4 939 }, 940 941 { 900 942 /* Content-Length */ 901 943 "Content-Length", "l", … … 1271 1313 if (rc != 0) 1272 1314 return rc; 1315 1316 return 0; 1317 } 1318 1319 /* 1320 NAME_ADDR ";q=0" 1321 */ 1322 static int hdr_test_contact_q0(pjsip_hdr *h) 1323 { 1324 pjsip_contact_hdr *hdr = (pjsip_contact_hdr*)h; 1325 int rc; 1326 1327 if (h->type != PJSIP_H_CONTACT) 1328 return -1710; 1329 1330 rc = nameaddr_test(hdr->uri); 1331 if (rc != 0) 1332 return rc; 1333 1334 if (hdr->q1000 != 0) 1335 return -1711; 1336 1337 return 0; 1338 } 1339 1340 /* 1341 NAME_ADDR ";q=0.5" 1342 */ 1343 static int hdr_test_contact_q1(pjsip_hdr *h) 1344 { 1345 pjsip_contact_hdr *hdr = (pjsip_contact_hdr*)h; 1346 int rc; 1347 1348 if (h->type != PJSIP_H_CONTACT) 1349 return -1710; 1350 1351 rc = nameaddr_test(hdr->uri); 1352 if (rc != 0) 1353 return rc; 1354 1355 if (hdr->q1000 != 500) 1356 return -1712; 1357 1358 return 0; 1359 } 1360 1361 /* 1362 NAME_ADDR ";q=1" 1363 */ 1364 static int hdr_test_contact_q2(pjsip_hdr *h) 1365 { 1366 pjsip_contact_hdr *hdr = (pjsip_contact_hdr*)h; 1367 int rc; 1368 1369 if (h->type != PJSIP_H_CONTACT) 1370 return -1710; 1371 1372 rc = nameaddr_test(hdr->uri); 1373 if (rc != 0) 1374 return rc; 1375 1376 if (hdr->q1000 != 1000) 1377 return -1713; 1378 1379 return 0; 1380 } 1381 1382 /* 1383 NAME_ADDR ";q=1.0" 1384 */ 1385 static int hdr_test_contact_q3(pjsip_hdr *h) 1386 { 1387 pjsip_contact_hdr *hdr = (pjsip_contact_hdr*)h; 1388 int rc; 1389 1390 if (h->type != PJSIP_H_CONTACT) 1391 return -1710; 1392 1393 rc = nameaddr_test(hdr->uri); 1394 if (rc != 0) 1395 return rc; 1396 1397 if (hdr->q1000 != 1000) 1398 return -1714; 1399 1400 return 0; 1401 } 1402 1403 /* 1404 NAME_ADDR ";q=1.15" 1405 */ 1406 static int hdr_test_contact_q4(pjsip_hdr *h) 1407 { 1408 pjsip_contact_hdr *hdr = (pjsip_contact_hdr*)h; 1409 int rc; 1410 1411 if (h->type != PJSIP_H_CONTACT) 1412 return -1710; 1413 1414 rc = nameaddr_test(hdr->uri); 1415 if (rc != 0) 1416 return rc; 1417 1418 if (hdr->q1000 != 1150) 1419 return -1715; 1273 1420 1274 1421 return 0;
Note: See TracChangeset
for help on using the changeset viewer.