Changeset 492 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
- Timestamp:
- Jun 6, 2006 6:40:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
r487 r492 212 212 /* Parse arguments. */ 213 213 PJ_DEF(pj_status_t) pjsua_parse_args(int argc, char *argv[], 214 pjsua_config *cfg) 214 pjsua_config *cfg, 215 pj_str_t *uri_to_call) 215 216 { 216 217 int c; … … 596 597 597 598 if (pj_optind != argc) { 599 pj_str_t uri_arg; 598 600 599 601 if (pjsua_verify_sip_url(argv[pj_optind]) != PJ_SUCCESS) { … … 601 603 return -1; 602 604 } 603 cfg->uri_to_call = pj_str(argv[pj_optind]); 605 uri_arg = pj_str(argv[pj_optind]); 606 if (uri_to_call) 607 *uri_to_call = uri_arg; 604 608 pj_optind++; 605 609 606 610 /* Add URI to call to buddy list if it's not already there */ 607 611 for (i=0; i<cfg->buddy_cnt; ++i) { 608 if (pj_stricmp(&cfg->buddy_uri[i], & cfg->uri_to_call)==0)612 if (pj_stricmp(&cfg->buddy_uri[i], &uri_arg)==0) 609 613 break; 610 614 } 611 615 if (i == cfg->buddy_cnt && cfg->buddy_cnt < PJSUA_MAX_BUDDIES) { 612 cfg->buddy_uri[cfg->buddy_cnt++] = cfg->uri_to_call; 613 } 616 cfg->buddy_uri[cfg->buddy_cnt++] = uri_arg; 617 } 618 619 } else { 620 if (uri_to_call) 621 uri_to_call->slen = 0; 614 622 } 615 623 … … 870 878 } 871 879 872 PJ_DEF(void) pjsua_ dump_call(int call_index, int with_media,880 PJ_DEF(void) pjsua_call_dump(int call_index, int with_media, 873 881 char *buffer, unsigned maxlen, 874 882 const char *indent) … … 976 984 for (i=0; i<pjsua.config.max_calls; ++i) { 977 985 if (pjsua.calls[i].inv) { 978 pjsua_ dump_call(i, detail, buf, sizeof(buf), " ");986 pjsua_call_dump(i, detail, buf, sizeof(buf), " "); 979 987 PJ_LOG(3,(THIS_FILE, "%s", buf)); 980 988 } … … 994 1002 */ 995 1003 PJ_DECL(pj_status_t) pjsua_load_settings(const char *filename, 996 pjsua_config *cfg) 1004 pjsua_config *cfg, 1005 pj_str_t *uri_to_call) 997 1006 { 998 1007 int argc = 3; … … 1000 1009 1001 1010 argv[2] = (char*)filename; 1002 return pjsua_parse_args(argc, argv, cfg );1011 return pjsua_parse_args(argc, argv, cfg, uri_to_call); 1003 1012 } 1004 1013 … … 1298 1307 * Get pjsua running config. 1299 1308 */ 1300 PJ_DEF(const pjsua_config*) pjsua_get_config(void) 1301 { 1302 return &pjsua.config; 1303 } 1304 1309 PJ_DEF(void) pjsua_get_config(pj_pool_t *pool, 1310 pjsua_config *cfg) 1311 { 1312 unsigned i; 1313 1314 pjsua_copy_config(pool, cfg, &pjsua.config); 1315 1316 /* Compact buddy uris. */ 1317 for (i=0; i<PJ_ARRAY_SIZE(pjsua.config.buddy_uri)-1; ++i) { 1318 if (pjsua.config.buddy_uri[i].slen == 0) { 1319 unsigned j; 1320 1321 for (j=i+1; j<PJ_ARRAY_SIZE(pjsua.config.buddy_uri); ++j) { 1322 if (pjsua.config.buddy_uri[j].slen != 0) 1323 break; 1324 } 1325 1326 if (j == PJ_ARRAY_SIZE(pjsua.config.buddy_uri)) 1327 break; 1328 else 1329 pjsua.config.buddy_uri[i] = pjsua.config.buddy_uri[j]; 1330 } 1331 } 1332 1333 /* Compact accounts. */ 1334 for (i=0; i<PJ_ARRAY_SIZE(pjsua.config.acc_config)-1; ++i) { 1335 1336 if (pjsua.acc[i].valid == PJ_FALSE || pjsua.acc[i].auto_gen) { 1337 unsigned j; 1338 1339 for (j=i+1; j<PJ_ARRAY_SIZE(pjsua.config.acc_config); ++j) { 1340 if (pjsua.acc[j].valid && !pjsua.acc[j].auto_gen) 1341 break; 1342 } 1343 1344 if (j == PJ_ARRAY_SIZE(pjsua.config.acc_config)) { 1345 break; 1346 } else { 1347 pj_memcpy(&pjsua.config.acc_config[i] , 1348 &pjsua.config.acc_config[j], 1349 sizeof(pjsua_acc_config)); 1350 } 1351 } 1352 1353 } 1354 1355 /* Remove auto generated account from config */ 1356 for (i=0; i<PJ_ARRAY_SIZE(pjsua.config.acc_config); ++i) { 1357 if (pjsua.acc[i].auto_gen) 1358 --cfg->acc_cnt; 1359 } 1360 } 1361 1362 1363 1364 /***************************************************************************** 1365 * This is a very simple PJSIP module, whose sole purpose is to display 1366 * incoming and outgoing messages to log. This module will have priority 1367 * higher than transport layer, which means: 1368 * 1369 * - incoming messages will come to this module first before reaching 1370 * transaction layer. 1371 * 1372 * - outgoing messages will come to this module last, after the message 1373 * has been 'printed' to contiguous buffer by transport layer and 1374 * appropriate transport instance has been decided for this message. 1375 * 1376 */ 1377 1378 /* Notification on incoming messages */ 1379 static pj_bool_t logging_on_rx_msg(pjsip_rx_data *rdata) 1380 { 1381 PJ_LOG(4,(THIS_FILE, "RX %d bytes %s from %s:%d:\n" 1382 "%s\n" 1383 "--end msg--", 1384 rdata->msg_info.len, 1385 pjsip_rx_data_get_info(rdata), 1386 rdata->pkt_info.src_name, 1387 rdata->pkt_info.src_port, 1388 rdata->msg_info.msg_buf)); 1389 1390 /* Always return false, otherwise messages will not get processed! */ 1391 return PJ_FALSE; 1392 } 1393 1394 /* Notification on outgoing messages */ 1395 static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata) 1396 { 1397 1398 /* Important note: 1399 * tp_info field is only valid after outgoing messages has passed 1400 * transport layer. So don't try to access tp_info when the module 1401 * has lower priority than transport layer. 1402 */ 1403 1404 PJ_LOG(4,(THIS_FILE, "TX %d bytes %s to %s:%d:\n" 1405 "%s\n" 1406 "--end msg--", 1407 (tdata->buf.cur - tdata->buf.start), 1408 pjsip_tx_data_get_info(tdata), 1409 tdata->tp_info.dst_name, 1410 tdata->tp_info.dst_port, 1411 tdata->buf.start)); 1412 1413 /* Always return success, otherwise message will not get sent! */ 1414 return PJ_SUCCESS; 1415 } 1416 1417 /* The module instance. */ 1418 pjsip_module pjsua_msg_logger = 1419 { 1420 NULL, NULL, /* prev, next. */ 1421 { "mod-pjsua-log", 13 }, /* Name. */ 1422 -1, /* Id */ 1423 PJSIP_MOD_PRIORITY_TRANSPORT_LAYER-1,/* Priority */ 1424 NULL, /* load() */ 1425 NULL, /* start() */ 1426 NULL, /* stop() */ 1427 NULL, /* unload() */ 1428 &logging_on_rx_msg, /* on_rx_request() */ 1429 &logging_on_rx_msg, /* on_rx_response() */ 1430 &logging_on_tx_msg, /* on_tx_request. */ 1431 &logging_on_tx_msg, /* on_tx_response() */ 1432 NULL, /* on_tsx_state() */ 1433 1434 }; 1435
Note: See TracChangeset
for help on using the changeset viewer.