Changeset 4476 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_config.c
- Timestamp:
- Apr 19, 2013 6:05:06 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_config.c
r4461 r4476 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 #include <pjsua-lib/pjsua.h>21 20 #include "pjsua_common.h" 22 21 … … 26 25 27 26 char *stdout_refresh_text = "STDOUT_REFRESH"; 28 29 /** This is for storing console runtime options **/30 static int cmd_argc;31 static char cmd_argv[MAX_APP_OPTIONS][MAX_APP_OPTIONS];32 27 33 28 /* Show usage */ … … 327 322 328 323 /* Parse arguments. */ 329 static pj_status_t parse_args(int argc, char *argv[], 330 pjsua_app_config *cfg, 324 static pj_status_t parse_args(int argc, char *argv[], 331 325 pj_str_t *uri_to_call) 332 326 { 333 327 int c; 334 328 int option_index; 329 pjsua_app_config *cfg = &app_config; 335 330 enum { OPT_CONFIG_FILE=127, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL, 336 331 OPT_LOG_APPEND, OPT_COLOR, OPT_NO_COLOR, OPT_LIGHT_BG, OPT_NO_STDERR, … … 1314 1309 1315 1310 case OPT_PLAY_AVI: 1316 if (app_config.avi_cnt >= MAX_AVI) {1311 if (app_config.avi_cnt >= PJSUA_APP_MAX_AVI) { 1317 1312 PJ_LOG(1,(THIS_FILE, "Too many AVIs")); 1318 1313 return -1; … … 1330 1325 1331 1326 case OPT_CLI_TELNET_PORT: 1332 cfg->cli_telnet_port = atoi(pj_optarg); 1327 cfg->cli_cfg.telnet_cfg.port = (pj_uint16_t)atoi(pj_optarg); 1328 cfg->cli_cfg.cli_fe |= CLI_FE_TELNET; 1333 1329 break; 1334 1330 1335 1331 case OPT_DISABLE_CLI_CONSOLE: 1336 cfg-> disable_cli_console = PJ_TRUE;1332 cfg->cli_cfg.cli_fe &= (~CLI_FE_CONSOLE); 1337 1333 break; 1338 1334 … … 1421 1417 1422 1418 /* Set default config. */ 1423 static void default_config( pjsua_app_config *cfg)1419 static void default_config() 1424 1420 { 1425 1421 char tmp[80]; 1426 1422 unsigned i; 1423 pjsua_app_config *cfg = &app_config; 1427 1424 1428 1425 pjsua_config_default(&cfg->cfg); … … 1438 1435 cfg->rtp_cfg.port = 4000; 1439 1436 cfg->redir_op = PJSIP_REDIRECT_ACCEPT_REPLACE; 1440 cfg->duration = NO_LIMIT_DURATION;1437 cfg->duration = PJSUA_APP_NO_LIMIT_DURATION; 1441 1438 cfg->wav_id = PJSUA_INVALID_ID; 1442 1439 cfg->rec_id = PJSUA_INVALID_ID; … … 1464 1461 1465 1462 cfg->use_cli = PJ_FALSE; 1466 cfg-> disable_cli_console = PJ_FALSE;1467 cfg->cli_ telnet_port = -1;1463 cfg->cli_cfg.cli_fe = CLI_FE_CONSOLE; 1464 cfg->cli_cfg.telnet_cfg.port = 0; 1468 1465 } 1469 1466 1470 static pj_status_t parse_config(int argc, char *argv[], 1471 pjsua_app_config *app_config, pj_str_t *uri_arg) 1467 static pj_status_t parse_config(int argc, char *argv[], pj_str_t *uri_arg) 1472 1468 { 1473 1469 pj_status_t status; … … 1477 1473 1478 1474 /* Parse the arguments */ 1479 status = parse_args(argc, argv, app_config,uri_arg);1475 status = parse_args(argc, argv, uri_arg); 1480 1476 return status; 1481 1477 } 1482 1478 1483 PJ_DEF(void) add_startup_config(int argc, char *argv[]) 1479 PJ_DEF(pj_status_t) load_config(int argc, 1480 char **argv, 1481 pj_str_t *uri_arg) 1484 1482 { 1485 int i;1486 cmd_argc = argc;1487 1488 for (i=0;i<argc;++i)1489 {1490 pj_memcpy(&cmd_argv[i], argv[i], strlen(argv[i]));1491 cmd_argv[i][strlen(argv[i])] = 0;1492 }1493 }1494 1495 PJ_DEF(void) add_reload_config(unsigned idx, pj_str_t *option)1496 {1497 /** First command always contain the app path**/1498 pj_str_t cmd;1499 1500 pj_assert(idx < MAX_APP_OPTIONS);1501 1502 cmd = pj_str(&cmd_argv[idx][0]);1503 pj_strncpy_with_null(&cmd, option, 128);1504 cmd_argc = idx+1;1505 }1506 1507 PJ_DEF(pj_status_t) load_config(pjsua_app_config *app_config,1508 pj_str_t *uri_arg,1509 pj_bool_t app_running)1510 {1511 int i;1512 int argc = cmd_argc;1513 char *argv[128];1514 1483 pj_status_t status; 1515 1484 pj_bool_t use_cli = PJ_FALSE; 1516 pj_bool_t disable_cli_console = PJ_TRUE;1517 int cli_telnet_port = 0;1485 int cli_fe = 0; 1486 pj_uint16_t cli_telnet_port = 0; 1518 1487 1519 1488 /** CLI options are not changable **/ 1520 1489 if (app_running) { 1521 use_cli = app_config->use_cli; 1522 disable_cli_console = app_config->disable_cli_console; 1523 cli_telnet_port = app_config->cli_telnet_port; 1524 } 1525 1526 for (i=0;i<cmd_argc;++i) 1527 { 1528 argv[i] = &cmd_argv[i][0]; 1529 } 1530 1531 status = parse_config(argc, argv, app_config, uri_arg); 1490 use_cli = app_config.use_cli; 1491 cli_fe = app_config.cli_cfg.cli_fe; 1492 cli_telnet_port = app_config.cli_cfg.telnet_cfg.port; 1493 } 1494 1495 status = parse_config(argc, argv, uri_arg); 1532 1496 if (status != PJ_SUCCESS) 1533 1497 return status; 1534 1498 1535 1499 if (app_running) { 1536 app_config ->use_cli = use_cli;1537 app_config ->disable_cli_console = disable_cli_console;1538 app_config ->cli_telnet_port = cli_telnet_port;1500 app_config.use_cli = use_cli; 1501 app_config.cli_cfg.cli_fe = cli_fe; 1502 app_config.cli_cfg.telnet_cfg.port = cli_telnet_port; 1539 1503 } 1540 1504 … … 2156 2120 2157 2121 /* Uas-duration. */ 2158 if (config->duration != NO_LIMIT_DURATION) {2122 if (config->duration != PJSUA_APP_NO_LIMIT_DURATION) { 2159 2123 pj_ansi_sprintf(line, "--duration %d\n", 2160 2124 config->duration);
Note: See TracChangeset
for help on using the changeset viewer.