Changeset 4729


Ignore:
Timestamp:
Feb 4, 2014 1:13:02 PM (10 years ago)
Author:
bennylp
Message:

Misc (re #1630): fix gcc warnings

Location:
pjproject/trunk/pjsip-apps/src/pjsua
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_cli.c

    r4724 r4729  
    11/* $Id$ */ 
    2 /*  
     2/* 
    33 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    44 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
     
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919 */ 
    2020 
     
    156156void cli_destroy(); 
    157157 
    158 PJ_DEF(void) cli_get_info(char *info, pj_size_t size)  
     158PJ_DEF(void) cli_get_info(char *info, pj_size_t size) 
    159159{ 
    160160    pj_cli_telnet_info telnet_info; 
     
    162162 
    163163    pj_ansi_snprintf(info, size, "Telnet to %.*s:%d", 
    164                      (int)telnet_info.ip_address.slen,  
    165                      telnet_info.ip_address.ptr,  
     164                     (int)telnet_info.ip_address.slen, 
     165                     telnet_info.ip_address.ptr, 
    166166                     telnet_info.port); 
    167167} 
     
    221221    if (app_config.cli_cfg.cli_fe & CLI_FE_CONSOLE) { 
    222222        pj_cli_console_cfg *fe_cfg = &app_config.cli_cfg.console_cfg; 
    223          
     223 
    224224        fe_cfg->quit_command = pj_str("shutdown"); 
    225225        status = pj_cli_console_create(cli, fe_cfg, 
     
    262262{ 
    263263    /* Destroy CLI, it will automatically destroy any FEs */ 
    264     if (cli) {           
     264    if (cli) { 
    265265        pj_cli_destroy(cli); 
    266266        cli = NULL; 
     
    281281 
    282282/* Get input URL */ 
    283 static void get_input_url(char *buf,  
     283static void get_input_url(char *buf, 
    284284                          pj_size_t len, 
    285285                          pj_cli_cmd_val *cval, 
     
    316316        for (; i<len; ++i) { 
    317317            if (!pj_isdigit(buf[i])) { 
    318                 pj_cli_sess_write_msg(cval->sess, err_invalid_input.ptr,  
     318                pj_cli_sess_write_msg(cval->sess, err_invalid_input.ptr, 
    319319                                      (int)err_invalid_input.slen); 
    320320                return; 
     
    324324        result->nb_result = my_atoi(buf); 
    325325 
    326         if (result->nb_result >= 0 &&  
    327             result->nb_result <= (int)pjsua_get_buddy_count())  
     326        if (result->nb_result >= 0 && 
     327            result->nb_result <= (int)pjsua_get_buddy_count()) 
    328328        { 
    329329            return; 
     
    332332            return; 
    333333 
    334         pj_cli_sess_write_msg(cval->sess, err_invalid_input.ptr,  
     334        pj_cli_sess_write_msg(cval->sess, err_invalid_input.ptr, 
    335335                              (int)err_invalid_input.slen); 
    336336        result->nb_result = PJSUA_APP_NO_NB; 
     
    353353static void get_buddy_id(pj_cli_dyn_choice_param *param) 
    354354{ 
    355     if (param->cnt < param->max_cnt) {   
     355    if (param->cnt < param->max_cnt) { 
    356356        pjsua_buddy_id ids[64]; 
    357357        int i = 0; 
     
    360360 
    361361        pjsua_enum_buddies(ids, &count); 
    362          
     362 
    363363        if (count > 0) { 
    364364            for (i=0; i<(int)count; ++i) { 
     
    372372                pj_strdup2(param->pool, &param->choice[i].value, data_out); 
    373373                pj_bzero(data_out, PJ_ARRAY_SIZE(data_out)); 
    374              
     374 
    375375                /* Format & fill description */ 
    376                 pj_ansi_snprintf(data_out,  
     376                pj_ansi_snprintf(data_out, 
    377377                                sizeof(data_out), 
    378                                 "<%.*s>  %.*s",                      
     378                                "<%.*s>  %.*s", 
    379379                                (int)info.status_text.slen, 
    380                                 info.status_text.ptr,  
     380                                info.status_text.ptr, 
    381381                                (int)info.uri.slen, 
    382382                                info.uri.ptr); 
    383383 
    384                 pj_strdup2(param->pool, &param->choice[i].desc, data_out);               
     384                pj_strdup2(param->pool, &param->choice[i].desc, data_out); 
    385385                if (++param->cnt >= (param->max_cnt-1)) 
    386                     break;       
     386                    break; 
    387387            } 
    388388        } 
     
    400400static void get_account_id(pj_cli_dyn_choice_param *param) 
    401401{ 
    402     if (param->cnt < param->max_cnt) {   
     402    if (param->cnt < param->max_cnt) { 
    403403        char buf[8]; 
    404404        char buf_out[80]; 
     
    407407        pjsua_acc_id acc_ids[16]; 
    408408        unsigned count = PJ_ARRAY_SIZE(acc_ids); 
    409         int i;     
     409        int i; 
    410410 
    411411        pjsua_enum_accs(acc_ids, &count); 
    412          
    413         for (i=0; i<(int)count; ++i) {   
     412 
     413        for (i=0; i<(int)count; ++i) { 
    414414            pj_bzero(&buf_out[0], PJ_ARRAY_SIZE(buf_out)); 
    415415 
    416416            pjsua_acc_get_info(acc_ids[i], &info); 
    417417 
    418             pj_ansi_snprintf(buf_out,  
     418            pj_ansi_snprintf(buf_out, 
    419419                             sizeof(buf_out), 
    420                              "%c%.*s",  
     420                             "%c%.*s", 
    421421                             (acc_ids[i]==current_acc?'*':' '), 
    422                              (int)info.acc_uri.slen,  
     422                             (int)info.acc_uri.slen, 
    423423                             info.acc_uri.ptr); 
    424424 
     
    428428            pj_strdup2(param->pool, &param->choice[i].desc, buf_out); 
    429429            if (++param->cnt >= param->max_cnt) 
    430                 break;   
     430                break; 
    431431        } 
    432432    } 
     
    450450        pjsua_conf_get_port_info(id[i], &info); 
    451451 
    452         pj_ansi_snprintf(slot_id, sizeof(slot_id),  
     452        pj_ansi_snprintf(slot_id, sizeof(slot_id), 
    453453                         "%d", info.slot_id); 
    454454        pj_strdup2(param->pool, &param->choice[i].value, slot_id); 
     
    459459            pj_ansi_snprintf(s, sizeof(s), "#%d ", info.listeners[j]); 
    460460            pj_ansi_strcat(txlist, s); 
    461         }        
    462  
    463         pj_ansi_snprintf(desc,   
     461        } 
     462 
     463        pj_ansi_snprintf(desc, 
    464464               sizeof(desc), 
    465                "[%2dKHz/%dms/%d] %20.*s  transmitting to: %s",          
     465               "[%2dKHz/%dms/%d] %20.*s  transmitting to: %s", 
    466466               info.clock_rate/1000, 
    467467               info.samples_per_frame*1000/info.channel_count/info.clock_rate, 
    468468               info.channel_count, 
    469                (int)info.name.slen,  
     469               (int)info.name.slen, 
    470470               info.name.ptr, 
    471471               txlist); 
    472472 
    473         pj_strdup2(param->pool, &param->choice[i].desc, desc);   
     473        pj_strdup2(param->pool, &param->choice[i].desc, desc); 
    474474        if (++param->cnt >= param->max_cnt) 
    475             break;       
     475            break; 
    476476    } 
    477477} 
     
    479479static void get_audio_codec_id(pj_cli_dyn_choice_param *param) 
    480480{ 
    481     if (param->cnt < param->max_cnt) {   
     481    if (param->cnt < param->max_cnt) { 
    482482        pjsua_codec_info c[32]; 
    483483        unsigned i, count = PJ_ARRAY_SIZE(c); 
    484484        char codec_id[64]; 
    485485        char desc[128]; 
    486          
     486 
    487487        pjsua_enum_codecs(c, &count); 
    488         for (i=0; i<count; ++i) {        
    489             pj_ansi_snprintf(codec_id, sizeof(codec_id),  
    490                              "%.*s", (int)c[i].codec_id.slen,  
     488        for (i=0; i<count; ++i) { 
     489            pj_ansi_snprintf(codec_id, sizeof(codec_id), 
     490                             "%.*s", (int)c[i].codec_id.slen, 
    491491                             c[i].codec_id.ptr); 
    492492 
    493493            pj_strdup2(param->pool, &param->choice[param->cnt].value, codec_id); 
    494494 
    495             pj_ansi_snprintf(desc, sizeof(desc),  
    496                              "Audio, prio: %d%s%.*s",  
    497                              c[i].priority,  
     495            pj_ansi_snprintf(desc, sizeof(desc), 
     496                             "Audio, prio: %d%s%.*s", 
     497                             c[i].priority, 
    498498                             c[i].desc.slen? " - ":"", 
    499499                             (int)c[i].desc.slen, 
     
    502502            pj_strdup2(param->pool, &param->choice[param->cnt].desc, desc); 
    503503            if (++param->cnt >= param->max_cnt) 
    504                 break;   
    505         } 
    506     } 
    507 } 
    508  
    509 #if PJSUA_HAS_VIDEO   
     504                break; 
     505        } 
     506    } 
     507} 
     508 
     509#if PJSUA_HAS_VIDEO 
    510510static void get_video_stream_id(pj_cli_dyn_choice_param *param) 
    511511{ 
    512     if (param->cnt < param->max_cnt) {   
     512    if (param->cnt < param->max_cnt) { 
    513513        pjsua_call_info call_info; 
    514514 
     
    519519                if (call_info.media[i].type == PJMEDIA_TYPE_VIDEO) { 
    520520                    char med_idx[8]; 
    521                     pj_ansi_snprintf(med_idx, sizeof(med_idx), "%d",  
     521                    pj_ansi_snprintf(med_idx, sizeof(med_idx), "%d", 
    522522                                     call_info.media[i].index); 
    523523                    pj_strdup2(param->pool, &param->choice[i].value, med_idx); 
    524524 
    525                     switch (call_info.media[i].status) {                     
     525                    switch (call_info.media[i].status) { 
    526526                    case PJSUA_CALL_MEDIA_NONE: 
    527                         pj_strdup2(param->pool, &param->choice[i].desc,  
     527                        pj_strdup2(param->pool, &param->choice[i].desc, 
    528528                                   "Status:None"); 
    529529                        break; 
    530530                    case PJSUA_CALL_MEDIA_ACTIVE: 
    531                         pj_strdup2(param->pool, &param->choice[i].desc,  
     531                        pj_strdup2(param->pool, &param->choice[i].desc, 
    532532                                   "Status:Active"); 
    533533                        break; 
    534534                    case PJSUA_CALL_MEDIA_LOCAL_HOLD: 
    535                         pj_strdup2(param->pool, &param->choice[i].desc,  
     535                        pj_strdup2(param->pool, &param->choice[i].desc, 
    536536                                   "Status:Local Hold"); 
    537537                        break; 
    538538                    case PJSUA_CALL_MEDIA_REMOTE_HOLD: 
    539                         pj_strdup2(param->pool, &param->choice[i].desc,  
     539                        pj_strdup2(param->pool, &param->choice[i].desc, 
    540540                                   "Status:Remote Hold"); 
    541541                        break; 
    542542                    case PJSUA_CALL_MEDIA_ERROR: 
    543                         pj_strdup2(param->pool, &param->choice[i].desc,  
     543                        pj_strdup2(param->pool, &param->choice[i].desc, 
    544544                                   "Status:Media Error"); 
    545545                        break; 
    546546                    } 
    547547                    if (++param->cnt >= param->max_cnt) 
    548                         break;   
     548                        break; 
    549549                } 
    550550            } 
     
    552552    } 
    553553} 
    554    
    555 static void get_video_dev_hint(pj_cli_dyn_choice_param *param,  
     554 
     555static void get_video_dev_hint(pj_cli_dyn_choice_param *param, 
    556556                               pjmedia_vid_dev_info *vdi, 
    557                                unsigned vid_dev_id)  
     557                               unsigned vid_dev_id) 
    558558{ 
    559559    char desc[128]; 
     
    561561    pj_ansi_snprintf(dev_id, sizeof(dev_id), 
    562562        "%d", vid_dev_id); 
    563     pj_ansi_snprintf(desc, sizeof(desc), "%s [%s]",  
     563    pj_ansi_snprintf(desc, sizeof(desc), "%s [%s]", 
    564564        vdi->name, vdi->driver); 
    565565 
    566     pj_strdup2(param->pool, &param->choice[param->cnt].value,  
     566    pj_strdup2(param->pool, &param->choice[param->cnt].value, 
    567567               dev_id); 
    568     pj_strdup2(param->pool, &param->choice[param->cnt].desc,  
    569                desc);     
    570 } 
    571  
    572 static void get_video_dev_id(pj_cli_dyn_choice_param *param,  
     568    pj_strdup2(param->pool, &param->choice[param->cnt].desc, 
     569               desc); 
     570} 
     571 
     572static void get_video_dev_id(pj_cli_dyn_choice_param *param, 
    573573                             pj_bool_t all, 
    574574                             pj_bool_t capture) 
    575575{ 
    576     if (param->cnt < param->max_cnt) {   
     576    if (param->cnt < param->max_cnt) { 
    577577        unsigned i, count; 
    578578        pjmedia_vid_dev_info vdi; 
     
    580580 
    581581        count = pjsua_vid_dev_count(); 
    582         if (count == 0) {        
     582        if (count == 0) { 
    583583            return; 
    584         }  
     584        } 
    585585 
    586586        for (i=0; i<count; ++i) { 
     
    590590                    ((capture) && (vdi.dir == PJMEDIA_DIR_CAPTURE)) || 
    591591                    ((!capture) && (vdi.dir == PJMEDIA_DIR_RENDER))) 
    592                 {                
     592                { 
    593593                    get_video_dev_hint(param, &vdi, i); 
    594594                    if (++param->cnt >= param->max_cnt) 
    595                         break;   
    596                 }  
     595                        break; 
     596                } 
    597597            } 
    598598        } 
     
    601601 
    602602static void get_video_codec_id(pj_cli_dyn_choice_param *param) 
    603 {     
    604     if (param->cnt < param->max_cnt) {   
     603{ 
     604    if (param->cnt < param->max_cnt) { 
    605605        pjsua_codec_info ci[32]; 
    606606        unsigned i, count = PJ_ARRAY_SIZE(ci); 
     
    620620            vfd = pjmedia_format_get_video_format_detail(&cp.enc_fmt, PJ_TRUE); 
    621621 
    622             pj_ansi_snprintf(codec_id, sizeof(codec_id),  
    623                              "%.*s", (int)ci[i].codec_id.slen,  
     622            pj_ansi_snprintf(codec_id, sizeof(codec_id), 
     623                             "%.*s", (int)ci[i].codec_id.slen, 
    624624                             ci[i].codec_id.ptr); 
    625625 
    626626            pj_strdup2(param->pool, &param->choice[param->cnt].value, codec_id); 
    627627 
    628             pj_ansi_snprintf(desc, sizeof(desc),  
    629                              "Video, p[%d], f[%.2f], b[%d/%d], s[%dx%d]",  
    630                              ci[i].priority,  
     628            pj_ansi_snprintf(desc, sizeof(desc), 
     629                             "Video, p[%d], f[%.2f], b[%d/%d], s[%dx%d]", 
     630                             ci[i].priority, 
    631631                             (vfd->fps.num*1.0/vfd->fps.denum), 
    632632                             vfd->avg_bps/1000, vfd->max_bps/1000, 
    633633                             vfd->size.w, vfd->size.h); 
    634634 
    635             pj_strdup2(param->pool, &param->choice[param->cnt].desc, desc);      
     635            pj_strdup2(param->pool, &param->choice[param->cnt].desc, desc); 
    636636            if (++param->cnt >= param->max_cnt) 
    637                 break;   
     637                break; 
    638638        } 
    639639    } 
     
    642642static void get_video_window_id(pj_cli_dyn_choice_param *param) 
    643643{ 
    644     if (param->cnt < param->max_cnt) {   
     644    if (param->cnt < param->max_cnt) { 
    645645        pjsua_vid_win_id wids[PJSUA_MAX_VID_WINS]; 
    646646        unsigned i, cnt = PJ_ARRAY_SIZE(wids); 
     
    657657            pj_strdup2(param->pool, &param->choice[i].value, win_id); 
    658658 
    659             pj_ansi_snprintf(desc, sizeof(desc),  
    660                              "Show:%c Pos(%d,%d)  Size(%dx%d)",  
     659            pj_ansi_snprintf(desc, sizeof(desc), 
     660                             "Show:%c Pos(%d,%d)  Size(%dx%d)", 
    661661                             (wi.show?'Y':'N'), wi.pos.x, wi.pos.y, 
    662662                             wi.size.w, wi.size.h); 
    663663 
    664             pj_strdup2(param->pool, &param->choice[i].desc, desc);       
     664            pj_strdup2(param->pool, &param->choice[i].desc, desc); 
    665665            if (++param->cnt >= param->max_cnt) 
    666                 break;   
     666                break; 
    667667        } 
    668668    } 
     
    671671static void get_call_id(pj_cli_dyn_choice_param *param) 
    672672{ 
    673     if (param->cnt < param->max_cnt) {   
     673    if (param->cnt < param->max_cnt) { 
    674674        char call_id[64]; 
    675675        char desc[128]; 
     
    691691                pj_ansi_snprintf(call_id, sizeof(call_id), "%d", ids[i]); 
    692692                pj_strdup2(param->pool, &param->choice[i].value, call_id); 
    693                 pj_ansi_snprintf(desc, sizeof(desc), "%.*s [%.*s]",  
     693                pj_ansi_snprintf(desc, sizeof(desc), "%.*s [%.*s]", 
    694694                    (int)call_info.remote_info.slen, 
    695695                    call_info.remote_info.ptr, 
     
    698698                pj_strdup2(param->pool, &param->choice[i].desc, desc); 
    699699                if (++param->cnt >= param->max_cnt) 
    700                     break;       
     700                    break; 
    701701 
    702702            } 
     
    723723        get_audio_codec_id(param); 
    724724        break; 
    725 #if PJSUA_HAS_VIDEO     
    726     case DYN_CHOICE_CAP_DEV_ID:  
     725#if PJSUA_HAS_VIDEO 
     726    case DYN_CHOICE_CAP_DEV_ID: 
    727727    case DYN_CHOICE_REN_DEV_ID: 
    728728    case DYN_CHOICE_VID_DEV_ID: 
    729         get_video_dev_id(param,  
     729        get_video_dev_id(param, 
    730730                         (param->arg_id==DYN_CHOICE_VID_DEV_ID), 
    731731                         (param->arg_id==DYN_CHOICE_CAP_DEV_ID)); 
     
    750750} 
    751751 
    752 /*  
     752/* 
    753753 * CLI command handler 
    754754 */ 
     
    777777        pjsua_perror(THIS_FILE, "Error adding new account", status); 
    778778    } 
    779      
     779 
    780780    return status; 
    781781} 
     
    790790 
    791791    if (!pjsua_acc_is_valid(i)) { 
    792         pj_ansi_snprintf(out_str, sizeof(out_str),  
     792        pj_ansi_snprintf(out_str, sizeof(out_str), 
    793793                        "Invalid account id %d\n", i); 
    794794        str_len = (unsigned)pj_ansi_strlen(out_str); 
     
    813813/* Register account */ 
    814814static pj_status_t cmd_reg_account() 
    815 {     
     815{ 
    816816    pjsua_acc_set_registration(current_acc, PJ_TRUE); 
    817817    return PJ_SUCCESS; 
     
    820820/* Unregister account */ 
    821821static pj_status_t cmd_unreg_account() 
    822 {     
     822{ 
    823823    pjsua_acc_set_registration(current_acc, PJ_FALSE); 
    824824    return PJ_SUCCESS; 
     
    834834    } else { 
    835835        PJ_LOG(3,(THIS_FILE, "Invalid account id %d", i)); 
    836     }     
     836    } 
    837837    return PJ_SUCCESS; 
    838838} 
     
    844844    unsigned count = PJ_ARRAY_SIZE(acc_ids); 
    845845    int i; 
    846     static const pj_str_t header = {"Account list:\n", 15};     
     846    static const pj_str_t header = {"Account list:\n", 15}; 
    847847 
    848848    pjsua_enum_accs(acc_ids, &count); 
     
    857857 
    858858        if (!info.has_registration) { 
    859             pj_ansi_snprintf(acc_info, sizeof(acc_info), "%.*s",  
     859            pj_ansi_snprintf(acc_info, sizeof(acc_info), "%.*s", 
    860860                             (int)info.status_text.slen, 
    861861                             info.status_text.ptr); 
     
    871871        } 
    872872 
    873         pj_ansi_snprintf(out_str, sizeof(out_str),  
    874                          " %c[%2d] %.*s: %s\n",  
    875                          (acc_ids[i]==current_acc?'*':' '), acc_ids[i],   
    876                          (int)info.acc_uri.slen, info.acc_uri.ptr,  
     873        pj_ansi_snprintf(out_str, sizeof(out_str), 
     874                         " %c[%2d] %.*s: %s\n", 
     875                         (acc_ids[i]==current_acc?'*':' '), acc_ids[i], 
     876                         (int)info.acc_uri.slen, info.acc_uri.ptr, 
    877877                         acc_info); 
    878878        pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 
     
    880880        pj_bzero(out_str, sizeof(out_str)); 
    881881        pj_ansi_snprintf(out_str, sizeof(out_str), 
    882                          "       Online status: %.*s\n",  
     882                         "       Online status: %.*s\n", 
    883883                         (int)info.online_status_text.slen, 
    884884                         info.online_status_text.ptr); 
     
    892892/* Account command handler */ 
    893893pj_status_t cmd_account_handler(pj_cli_cmd_val *cval) 
    894 {     
     894{ 
    895895    pj_status_t status = PJ_SUCCESS; 
    896896 
     
    913913        status = cmd_unreg_account(); 
    914914        break; 
    915     case CMD_ACCOUNT_NEXT:       
     915    case CMD_ACCOUNT_NEXT: 
    916916    case CMD_ACCOUNT_PREV: 
    917         status = cmd_next_account(cval);         
     917        status = cmd_next_account(cval); 
    918918        break; 
    919919    case CMD_ACCOUNT_SHOW: 
    920920        status = cmd_show_account(cval); 
    921921        break; 
    922     }     
     922    } 
    923923    return status; 
    924924} 
     
    926926/* Add buddy */ 
    927927static pj_status_t cmd_add_buddy(pj_cli_cmd_val *cval) 
    928 {     
     928{ 
    929929    char out_str[80]; 
    930930    pjsua_buddy_config buddy_cfg; 
     
    934934 
    935935    if (pjsua_verify_url(cval->argv[1].ptr) != PJ_SUCCESS) { 
    936         pj_ansi_snprintf(out_str, sizeof(out_str),  
     936        pj_ansi_snprintf(out_str, sizeof(out_str), 
    937937                         "Invalid URI '%s'\n", cval->argv[1].ptr); 
    938938    } else { 
     
    944944        status = pjsua_buddy_add(&buddy_cfg, &buddy_id); 
    945945        if (status == PJ_SUCCESS) { 
    946             pj_ansi_snprintf(out_str, sizeof(out_str),  
     946            pj_ansi_snprintf(out_str, sizeof(out_str), 
    947947                              "New buddy '%s' added at index %d\n", 
    948948                              cval->argv[1].ptr, buddy_id+1); 
    949         }    
     949        } 
    950950    } 
    951951    pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 
     
    955955/* Delete buddy */ 
    956956static pj_status_t cmd_del_buddy(pj_cli_cmd_val *cval) 
    957 {     
     957{ 
    958958    int i = my_atoi(cval->argv[1].ptr) - 1; 
    959959    char out_str[80]; 
    960960 
    961961    if (!pjsua_buddy_is_valid(i)) { 
    962         pj_ansi_snprintf(out_str, sizeof(out_str),  
    963                          "Invalid buddy id %d\n", i);    
     962        pj_ansi_snprintf(out_str, sizeof(out_str), 
     963                         "Invalid buddy id %d\n", i); 
    964964    } else { 
    965965        pjsua_buddy_del(i); 
    966         pj_ansi_snprintf(out_str, sizeof(out_str),  
    967                          "Buddy %d deleted\n", i);               
     966        pj_ansi_snprintf(out_str, sizeof(out_str), 
     967                         "Buddy %d deleted\n", i); 
    968968    } 
    969969    pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 
     
    973973/* Send IM */ 
    974974static pj_status_t cmd_send_im(pj_cli_cmd_val *cval) 
    975 {     
    976     int i = -1;     
     975{ 
     976    int i = -1; 
    977977    struct input_result result; 
    978978    char dest[64]; 
    979     pj_str_t tmp = pj_str(dest);     
     979    pj_str_t tmp = pj_str(dest); 
    980980 
    981981    /* make compiler happy. */ 
     
    983983 
    984984    pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 
    985      
     985 
    986986    /* input destination. */ 
    987987    get_input_url(tmp.ptr, tmp.slen, cval, &result); 
    988988    if (result.nb_result != PJSUA_APP_NO_NB) { 
    989989 
    990         if (result.nb_result == -1) {        
     990        if (result.nb_result == -1) { 
    991991            static const pj_str_t err_msg = {"you can't send broadcast im " 
    992                                              "like that!\n", 40 };           
     992                                             "like that!\n", 40 }; 
    993993            pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 
    994994            return PJ_SUCCESS; 
     
    997997        } else { 
    998998            pjsua_buddy_info binfo; 
    999             pjsua_buddy_get_info(result.nb_result-1, &binfo);        
     999            pjsua_buddy_get_info(result.nb_result-1, &binfo); 
    10001000            pj_strncpy_with_null(&tmp, &binfo.uri, sizeof(dest)); 
    10011001            uri = tmp.ptr; 
     
    10261026/* Subscribe/unsubscribe presence */ 
    10271027static pj_status_t cmd_subs_pres(pj_cli_cmd_val *cval, pj_bool_t subscribe) 
    1028 {    
    1029     struct input_result result;     
     1028{ 
     1029    struct input_result result; 
    10301030    char dest[64] = {0}; 
    10311031    pj_str_t tmp = pj_str(dest); 
    1032      
     1032 
    10331033    pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 
    1034     get_input_url(tmp.ptr, tmp.slen, cval, &result);     
     1034    get_input_url(tmp.ptr, tmp.slen, cval, &result); 
    10351035    if (result.nb_result != PJSUA_APP_NO_NB) { 
    10361036        if (result.nb_result == -1) { 
     
    10591059/* Toggle online state */ 
    10601060static pj_status_t cmd_toggle_state(pj_cli_cmd_val *cval) 
    1061 {     
     1061{ 
    10621062    char out_str[128]; 
    10631063    pjsua_acc_info acc_info; 
     
    10661066    acc_info.online_status = !acc_info.online_status; 
    10671067    pjsua_acc_set_online_status(current_acc, acc_info.online_status); 
    1068     pj_ansi_snprintf(out_str, sizeof(out_str),  
     1068    pj_ansi_snprintf(out_str, sizeof(out_str), 
    10691069                     "Setting %s online status to %s\n", 
    10701070                     acc_info.acc_uri.ptr, 
     
    10761076/* Set presence text */ 
    10771077static pj_status_t cmd_set_presence_text(pj_cli_cmd_val *cval) 
    1078 {     
     1078{ 
    10791079    pjrpid_element elem; 
    10801080    int choice; 
     
    11251125/* Show buddy list */ 
    11261126static pj_status_t cmd_show_buddy(pj_cli_cmd_val *cval) 
    1127 {         
     1127{ 
    11281128    pjsua_buddy_id ids[64]; 
    11291129    int i; 
    11301130    unsigned count = PJ_ARRAY_SIZE(ids); 
    1131     static const pj_str_t header = {"Buddy list:\n", 13};     
     1131    static const pj_str_t header = {"Buddy list:\n", 13}; 
    11321132    char out_str[64]; 
    11331133 
     
    11401140        pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 
    11411141    } else { 
    1142         for (i=0; i<(int)count; ++i) {       
     1142        for (i=0; i<(int)count; ++i) { 
    11431143            pjsua_buddy_info info; 
    11441144            pj_bzero(out_str, sizeof(out_str)); 
     
    11471147                continue; 
    11481148 
    1149             pj_ansi_snprintf(out_str, sizeof(out_str),  
    1150                     " [%2d] <%.*s>  %.*s\n",  
    1151                     ids[i]+1,  
     1149            pj_ansi_snprintf(out_str, sizeof(out_str), 
     1150                    " [%2d] <%.*s>  %.*s\n", 
     1151                    ids[i]+1, 
    11521152                    (int)info.status_text.slen, 
    1153                     info.status_text.ptr,  
     1153                    info.status_text.ptr, 
    11541154                    (int)info.uri.slen, 
    11551155                    info.uri.ptr); 
     
    11571157            pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 
    11581158        } 
    1159     }         
     1159    } 
    11601160    return PJ_SUCCESS; 
    11611161} 
     
    11631163/* Presence/buddy command handler */ 
    11641164pj_status_t cmd_presence_handler(pj_cli_cmd_val *cval) 
    1165 {     
     1165{ 
    11661166    pj_status_t status = PJ_SUCCESS; 
    11671167 
     
    11781178        status = cmd_send_im(cval); 
    11791179        break; 
    1180     case CMD_PRESENCE_SUB:       
     1180    case CMD_PRESENCE_SUB: 
    11811181    case CMD_PRESENCE_UNSUB: 
    1182         status = cmd_subs_pres(cval,  
    1183                                pj_cli_get_cmd_id(cval->cmd)==CMD_PRESENCE_SUB);  
     1182        status = cmd_subs_pres(cval, 
     1183                               pj_cli_get_cmd_id(cval->cmd)==CMD_PRESENCE_SUB); 
    11841184        break; 
    11851185    case CMD_PRESENCE_TOG_STATE: 
     
    11921192        status = cmd_show_buddy(cval); 
    11931193        break; 
    1194     }     
     1194    } 
    11951195 
    11961196    return status; 
     
    12041204    static const pj_str_t header = {"Conference ports:\n", 19}; 
    12051205 
    1206     pj_cli_sess_write_msg(cval->sess, header.ptr, header.slen);     
     1206    pj_cli_sess_write_msg(cval->sess, header.ptr, header.slen); 
    12071207 
    12081208    count = PJ_ARRAY_SIZE(id); 
     
    12231223            pj_ansi_strcat(txlist, s); 
    12241224        } 
    1225         pj_ansi_snprintf(out_str,  
     1225        pj_ansi_snprintf(out_str, 
    12261226               sizeof(out_str), 
    1227                "Port #%02d[%2dKHz/%dms/%d] %20.*s  transmitting to: %s\n",  
    1228                info.slot_id,  
     1227               "Port #%02d[%2dKHz/%dms/%d] %20.*s  transmitting to: %s\n", 
     1228               info.slot_id, 
    12291229               info.clock_rate/1000, 
    12301230               info.samples_per_frame*1000/info.channel_count/info.clock_rate, 
    12311231               info.channel_count, 
    1232                (int)info.name.slen,  
     1232               (int)info.name.slen, 
    12331233               info.name.ptr, 
    12341234               txlist); 
    1235         pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str));     
    1236     }     
     1235        pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 
     1236    } 
    12371237    return PJ_SUCCESS; 
    12381238} 
     
    12421242{ 
    12431243    pj_status_t status; 
    1244      
     1244 
    12451245    if (connect) 
    1246         status = pjsua_conf_connect(pj_strtol(&cval->argv[1]),  
     1246        status = pjsua_conf_connect(pj_strtol(&cval->argv[1]), 
    12471247                                    pj_strtol(&cval->argv[2])); 
    12481248    else 
    1249         status = pjsua_conf_disconnect(pj_strtol(&cval->argv[1]),  
     1249        status = pjsua_conf_disconnect(pj_strtol(&cval->argv[1]), 
    12501250                                       pj_strtol(&cval->argv[2])); 
    12511251 
    12521252    if (status == PJ_SUCCESS) { 
    12531253        static const pj_str_t success_msg = {"Success\n", 9}; 
    1254         pj_cli_sess_write_msg(cval->sess, success_msg.ptr, success_msg.slen);    
     1254        pj_cli_sess_write_msg(cval->sess, success_msg.ptr, success_msg.slen); 
    12551255    } else { 
    12561256        static const pj_str_t err_msg = {"ERROR!!\n", 9}; 
     
    12701270 
    12711271    /* Adjust mic level */ 
    1272     orig_level = app_config.mic_level;     
     1272    orig_level = app_config.mic_level; 
    12731273    pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(level_val)); 
    12741274    app_config.mic_level = (float)strtod(level_val, &err); 
     
    12761276 
    12771277    pj_ansi_snprintf(buf, sizeof(buf), 
    1278                      "Adjust mic level: [%4.1fx] -> [%4.1fx]\n",  
     1278                     "Adjust mic level: [%4.1fx] -> [%4.1fx]\n", 
    12791279                     orig_level, app_config.mic_level); 
    12801280 
     
    12821282 
    12831283    /* Adjust speaker level */ 
    1284     orig_level = app_config.speaker_level;         
     1284    orig_level = app_config.speaker_level; 
    12851285    pj_strncpy_with_null(&tmp, &cval->argv[2], sizeof(level_val)); 
    12861286    app_config.speaker_level = (float)strtod(level_val, &err); 
     
    12881288 
    12891289    pj_ansi_snprintf(buf, sizeof(buf), 
    1290                       "Adjust speaker level: [%4.1fx] -> [%4.1fx]\n",  
     1290                      "Adjust speaker level: [%4.1fx] -> [%4.1fx]\n", 
    12911291                      orig_level, app_config.speaker_level); 
    12921292 
     
    12981298/* Set codec priority */ 
    12991299static pj_status_t cmd_set_codec_prio(pj_cli_cmd_val *cval) 
    1300 {         
    1301     int new_prio;     
    1302     pj_status_t status;     
     1300{ 
     1301    int new_prio; 
     1302    pj_status_t status; 
    13031303 
    13041304    new_prio = pj_strtol(&cval->argv[2]); 
    1305     if (new_prio < 0)  
     1305    if (new_prio < 0) 
    13061306        new_prio = 0; 
    1307     else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST)  
     1307    else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST) 
    13081308        new_prio = PJMEDIA_CODEC_PRIO_HIGHEST; 
    13091309 
    1310     status = pjsua_codec_set_priority(&cval->argv[1],  
     1310    status = pjsua_codec_set_priority(&cval->argv[1], 
    13111311                                      (pj_uint8_t)new_prio); 
    13121312#if PJSUA_HAS_VIDEO 
    13131313    if (status != PJ_SUCCESS) { 
    1314         status = pjsua_vid_codec_set_priority(&cval->argv[1],  
     1314        status = pjsua_vid_codec_set_priority(&cval->argv[1], 
    13151315                                              (pj_uint8_t)new_prio); 
    13161316    } 
     
    13351335    case CMD_MEDIA_CONF_CONNECT: 
    13361336    case CMD_MEDIA_CONF_DISCONNECT: 
    1337         status = cmd_media_connect(cval,  
    1338                           pj_cli_get_cmd_id(cval->cmd)==CMD_MEDIA_CONF_CONNECT);         
    1339         break; 
    1340     case CMD_MEDIA_ADJUST_VOL:   
     1337        status = cmd_media_connect(cval, 
     1338                          pj_cli_get_cmd_id(cval->cmd)==CMD_MEDIA_CONF_CONNECT); 
     1339        break; 
     1340    case CMD_MEDIA_ADJUST_VOL: 
    13411341        status = cmd_adjust_vol(cval); 
    13421342        break; 
    13431343    case CMD_MEDIA_CODEC_PRIO: 
    1344         status = cmd_set_codec_prio(cval);       
     1344        status = cmd_set_codec_prio(cval); 
    13451345        break; 
    13461346    case CMD_MEDIA_SPEAKER_TOGGLE: 
     
    13691369        } 
    13701370        break; 
    1371     }     
     1371    } 
    13721372 
    13731373    return status; 
     
    13901390        PJ_LOG(1,(THIS_FILE, "Error: not enough buffer")); 
    13911391    else 
    1392         PJ_LOG(3,(THIS_FILE,  
     1392        PJ_LOG(3,(THIS_FILE, 
    13931393                  "Dumping configuration (%d bytes):\n%s\n", 
    13941394                  len, settings)); 
     
    14041404    pj_str_t tmp = pj_str(buf); 
    14051405 
    1406     pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(buf));     
     1406    pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(buf)); 
    14071407 
    14081408    len = write_settings(&app_config, settings, sizeof(settings)); 
     
    14471447        break; 
    14481448    case CMD_CONFIG_DUMP_CONF: 
    1449         status = cmd_show_config();      
    1450         break; 
    1451     case CMD_CONFIG_WRITE_SETTING:       
     1449        status = cmd_show_config(); 
     1450        break; 
     1451    case CMD_CONFIG_WRITE_SETTING: 
    14521452        status = cmd_write_config(cval); 
    14531453        break; 
    1454     }     
     1454    } 
    14551455 
    14561456    return status; 
     
    14631463    char dest[64] = {0}; 
    14641464    char out_str[128]; 
    1465     pj_str_t tmp = pj_str(dest);       
    1466  
    1467     pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest));     
    1468  
    1469     pj_ansi_snprintf(out_str,  
    1470                      sizeof(out_str),  
     1465    pj_str_t tmp = pj_str(dest); 
     1466 
     1467    pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 
     1468 
     1469    pj_ansi_snprintf(out_str, 
     1470                     sizeof(out_str), 
    14711471                     "(You currently have %d calls)\n", 
    14721472                     pjsua_call_get_count()); 
    14731473 
    14741474    pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 
    1475      
     1475 
    14761476    /* input destination. */ 
    1477     get_input_url(tmp.ptr, tmp.slen, cval, &result);     
     1477    get_input_url(tmp.ptr, tmp.slen, cval, &result); 
    14781478    if (result.nb_result != PJSUA_APP_NO_NB) { 
    14791479        pjsua_buddy_info binfo; 
    14801480        if (result.nb_result == -1 || result.nb_result == 0) { 
    1481             static const pj_str_t err_msg =  
     1481            static const pj_str_t err_msg = 
    14821482                    {"You can't do that with make call!\n", 35}; 
    14831483            pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 
    14841484            return PJ_SUCCESS; 
    1485         }        
    1486         pjsua_buddy_get_info(result.nb_result-1, &binfo);            
     1485        } 
     1486        pjsua_buddy_get_info(result.nb_result-1, &binfo); 
    14871487        pj_strncpy(&tmp, &binfo.uri, sizeof(dest)); 
    14881488    } else if (result.uri_result) { 
     
    14941494    pjsua_msg_data_init(&msg_data); 
    14951495    TEST_MULTIPART(&msg_data); 
    1496     pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL,  
     1496    pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, 
    14971497                         &msg_data, &current_call); 
    14981498    return PJ_SUCCESS; 
     
    15031503{ 
    15041504    struct input_result result; 
    1505     char dest[64] = {0};     
     1505    char dest[64] = {0}; 
    15061506    char out_str[128]; 
    15071507    int i, count; 
    15081508    pj_str_t tmp = pj_str(dest); 
    15091509 
    1510     pj_ansi_snprintf(out_str,  
    1511                      sizeof(out_str),  
     1510    pj_ansi_snprintf(out_str, 
     1511                     sizeof(out_str), 
    15121512                     "(You currently have %d calls)\n", 
    15131513                     pjsua_call_get_count()); 
    1514      
     1514 
    15151515    count = pj_strtol(&cval->argv[1]); 
    15161516    if (count < 1) 
    15171517        return PJ_SUCCESS; 
    1518      
     1518 
    15191519    pj_strncpy_with_null(&tmp, &cval->argv[2], sizeof(dest)); 
    1520      
     1520 
    15211521    /* input destination. */ 
    1522     get_input_url(tmp.ptr, tmp.slen, cval, &result);     
     1522    get_input_url(tmp.ptr, tmp.slen, cval, &result); 
    15231523    if (result.nb_result != PJSUA_APP_NO_NB) { 
    15241524        pjsua_buddy_info binfo; 
    15251525        if (result.nb_result == -1 || result.nb_result == 0) { 
    1526             static const pj_str_t err_msg =  
     1526            static const pj_str_t err_msg = 
    15271527                            {"You can't do that with make call!\n", 35}; 
    15281528            pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 
    15291529            return PJ_SUCCESS; 
    1530         }        
    1531         pjsua_buddy_get_info(result.nb_result-1, &binfo);            
    1532         pj_strncpy(&tmp, &binfo.uri, sizeof(dest));      
     1530        } 
     1531        pjsua_buddy_get_info(result.nb_result-1, &binfo); 
     1532        pj_strncpy(&tmp, &binfo.uri, sizeof(dest)); 
    15331533    } else { 
    15341534        tmp = pj_str(result.uri_result); 
    1535     }  
     1535    } 
    15361536 
    15371537    for (i=0; i<count; ++i) { 
     
    15591559    } 
    15601560 
    1561     if (current_call == PJSUA_INVALID_ID ||  
     1561    if (current_call == PJSUA_INVALID_ID || 
    15621562        call_info.role != PJSIP_ROLE_UAS || 
    15631563        call_info.state >= PJSIP_INV_STATE_CONNECTING) 
    1564     {    
    1565         static const pj_str_t err_msg = {"No pending incoming call\n", 26};        
     1564    { 
     1565        static const pj_str_t err_msg = {"No pending incoming call\n", 26}; 
    15661566        pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 
    15671567 
     
    15701570        char contact[120]; 
    15711571        pj_str_t hname = { "Contact", 7 }; 
    1572         pj_str_t hvalue;         
    1573         pjsip_generic_string_hdr hcontact;       
     1572        pj_str_t hvalue; 
     1573        pjsip_generic_string_hdr hcontact; 
    15741574 
    15751575        st_code = pj_strtol(&cval->argv[1]); 
     
    15831583                static const pj_str_t err_msg = {"Enter URL to be put " 
    15841584                                                 "in Contact\n",  32}; 
    1585                 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen);            
     1585                pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 
    15861586                return PJ_SUCCESS; 
    15871587            } 
     
    15951595        /* 
    15961596        * Must check again! 
    1597         * Call may have been disconnected while we're waiting for  
     1597        * Call may have been disconnected while we're waiting for 
    15981598        * keyboard input. 
    15991599        */ 
    16001600        if (current_call == PJSUA_INVALID_ID) { 
    1601             static const pj_str_t err_msg = {"Call has been disconnected\n",  
    1602                                              28};            
     1601            static const pj_str_t err_msg = {"Call has been disconnected\n", 
     1602                                             28}; 
    16031603            pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 
    16041604        } 
     
    16171617    } else { 
    16181618        if (all) 
    1619             pjsua_call_hangup_all();         
     1619            pjsua_call_hangup_all(); 
    16201620        else 
    16211621            pjsua_call_hangup(current_call, 0, NULL, NULL); 
     
    16271627static pj_status_t cmd_hold_call() 
    16281628{ 
    1629     if (current_call != PJSUA_INVALID_ID) {      
     1629    if (current_call != PJSUA_INVALID_ID) { 
    16301630        pjsua_call_set_hold(current_call, NULL); 
    16311631 
     
    16751675    } 
    16761676 
    1677     if (current_call != PJSUA_INVALID_ID) {      
     1677    if (current_call != PJSUA_INVALID_ID) { 
    16781678        pjsua_call_info call_info; 
    16791679 
    16801680        pjsua_call_get_info(current_call, &call_info); 
    1681         PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s",  
    1682                   (int)call_info.remote_info.slen,  
     1681        PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s", 
     1682                  (int)call_info.remote_info.slen, 
    16831683                  call_info.remote_info.ptr)); 
    16841684 
     
    17061706        pj_str_t STR_FALSE = { "false", 5 }; 
    17071707        pjsua_call_info ci; 
    1708          
    1709         pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest));        
     1708 
     1709        pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 
    17101710 
    17111711        pjsua_call_get_info(current_call, &ci); 
    1712         pj_ansi_snprintf(out_str,  
    1713                          sizeof(out_str),  
     1712        pj_ansi_snprintf(out_str, 
     1713                         sizeof(out_str), 
    17141714                         "Transferring current call [%d] %.*s\n", 
    17151715                         current_call, 
    1716                          (int)ci.remote_info.slen,  
     1716                         (int)ci.remote_info.slen, 
    17171717                         ci.remote_info.ptr); 
    17181718 
     
    17491749            pjsua_call_xfer( current_call, &tmp, &msg_data); 
    17501750        } 
    1751     }        
     1751    } 
    17521752    return PJ_SUCCESS; 
    17531753} 
     
    17551755/* Transfer call */ 
    17561756static pj_status_t cmd_transfer_replace_call(pj_cli_cmd_val *cval) 
    1757 {     
     1757{ 
    17581758    if (current_call == -1) { 
    17591759        PJ_LOG(3,(THIS_FILE, "No current call")); 
     
    17641764        pj_str_t STR_REFER_SUB = { "Refer-Sub", 9 }; 
    17651765        pj_str_t STR_FALSE = { "false", 5 }; 
    1766         pjsua_call_id ids[PJSUA_MAX_CALLS];      
     1766        pjsua_call_id ids[PJSUA_MAX_CALLS]; 
    17671767        pjsua_msg_data msg_data; 
    1768         char buf[8] = {0};       
     1768        char buf[8] = {0}; 
    17691769        pj_str_t tmp = pj_str(buf); 
    1770         unsigned count;  
    1771         static const pj_str_t err_invalid_num =  
     1770        unsigned count; 
     1771        static const pj_str_t err_invalid_num = 
    17721772                                    {"Invalid destination call number\n", 32 }; 
    17731773        count = PJ_ARRAY_SIZE(ids); 
    17741774        pjsua_enum_calls(ids, &count); 
    17751775 
    1776         if (count <= 1) {            
    1777             static const pj_str_t err_no_other_call =  
     1776        if (count <= 1) { 
     1777            static const pj_str_t err_no_other_call = 
    17781778                                    {"There are no other calls\n", 25}; 
    17791779 
    1780             pj_cli_sess_write_msg(cval->sess, err_no_other_call.ptr,  
     1780            pj_cli_sess_write_msg(cval->sess, err_no_other_call.ptr, 
    17811781                                  err_no_other_call.slen); 
    17821782            return PJ_SUCCESS; 
     
    17871787 
    17881788        /* Check if call is still there. */ 
    1789         if (call != current_call) {          
    1790             static pj_str_t err_call_dc =  
     1789        if (call != current_call) { 
     1790            static pj_str_t err_call_dc = 
    17911791                                    {"Call has been disconnected\n", 27}; 
    17921792 
    1793             pj_cli_sess_write_msg(cval->sess, err_call_dc.ptr,  
     1793            pj_cli_sess_write_msg(cval->sess, err_call_dc.ptr, 
    17941794                                  err_call_dc.slen); 
    17951795            return PJ_SUCCESS; 
     
    17981798        /* Check that destination call is valid. */ 
    17991799        if (dst_call == call) { 
    1800             static pj_str_t err_same_num =  
     1800            static pj_str_t err_same_num = 
    18011801                                    {"Destination call number must not be the " 
    18021802                                     "same as the call being transferred\n", 74}; 
    18031803 
    1804             pj_cli_sess_write_msg(cval->sess, err_same_num.ptr,  
     1804            pj_cli_sess_write_msg(cval->sess, err_same_num.ptr, 
    18051805                                  err_same_num.slen); 
    18061806            return PJ_SUCCESS; 
     
    18081808 
    18091809        if (dst_call >= PJSUA_MAX_CALLS) { 
    1810             pj_cli_sess_write_msg(cval->sess, err_invalid_num.ptr,  
     1810            pj_cli_sess_write_msg(cval->sess, err_invalid_num.ptr, 
    18111811                                  err_invalid_num.slen); 
    18121812            return PJ_SUCCESS; 
     
    18141814 
    18151815        if (!pjsua_call_is_active(dst_call)) { 
    1816             pj_cli_sess_write_msg(cval->sess, err_invalid_num.ptr,  
     1816            pj_cli_sess_write_msg(cval->sess, err_invalid_num.ptr, 
    18171817                                  err_invalid_num.slen); 
    18181818            return PJ_SUCCESS; 
     
    18221822        if (app_config.no_refersub) { 
    18231823            /* Add Refer-Sub: false in outgoing REFER request */ 
    1824             pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB,  
     1824            pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, 
    18251825                                           &STR_FALSE); 
    18261826            pj_list_push_back(&msg_data.hdr_list, &refer_sub); 
    18271827        } 
    18281828 
    1829         pjsua_call_xfer_replaces(call, dst_call,  
    1830                                  PJSUA_XFER_NO_REQUIRE_REPLACES,  
     1829        pjsua_call_xfer_replaces(call, dst_call, 
     1830                                 PJSUA_XFER_NO_REQUIRE_REPLACES, 
    18311831                                 &msg_data); 
    18321832    } 
     
    18351835 
    18361836static pj_status_t cmd_redirect_call(pj_cli_cmd_val *cval) 
    1837 {   
     1837{ 
    18381838    if (current_call == PJSUA_INVALID_ID) { 
    18391839        PJ_LOG(3,(THIS_FILE, "No current call")); 
     
    18421842    if (!pjsua_call_is_active(current_call)) { 
    18431843        PJ_LOG(1,(THIS_FILE, "Call %d has gone", current_call)); 
    1844     } else {     
     1844    } else { 
    18451845        enum { 
    18461846            ACCEPT_REPLACE, ACCEPT, REJECT, STOP 
     
    18501850        switch (choice) { 
    18511851        case ACCEPT_REPLACE: 
    1852             pjsua_call_process_redirect(current_call,  
    1853                                         PJSIP_REDIRECT_ACCEPT_REPLACE);      
     1852            pjsua_call_process_redirect(current_call, 
     1853                                        PJSIP_REDIRECT_ACCEPT_REPLACE); 
    18541854            break; 
    18551855        case ACCEPT: 
     
    18621862            pjsua_call_process_redirect(current_call, PJSIP_REDIRECT_STOP); 
    18631863            break; 
    1864         }        
     1864        } 
    18651865    } 
    18661866    return PJ_SUCCESS; 
     
    18781878        PJ_LOG(3,(THIS_FILE, "Media is not established yet!")); 
    18791879 
    1880     } else {     
     1880    } else { 
    18811881        int call = current_call; 
    18821882        pj_status_t status; 
     
    18881888            return PJ_SUCCESS;; 
    18891889        } 
    1890          
     1890 
    18911891        status = pjsua_call_dial_dtmf(current_call, &cval->argv[1]); 
    18921892        if (status != PJ_SUCCESS) { 
     
    19091909 
    19101910    } else { 
    1911         const pj_str_t SIP_INFO = pj_str("INFO");        
     1911        const pj_str_t SIP_INFO = pj_str("INFO"); 
    19121912        int call = current_call; 
    19131913        int i; 
     
    19201920            return PJ_SUCCESS;; 
    19211921        } 
    1922          
     1922 
    19231923        for (i=0; i<cval->argv[1].slen; ++i) { 
    19241924            char body[64]; 
     
    19271927            msg_data.content_type = pj_str("application/dtmf-relay"); 
    19281928 
    1929             pj_ansi_snprintf(body,  
     1929            pj_ansi_snprintf(body, 
    19301930                             sizeof(body), 
    19311931                             "Signal=%c\n" 
     
    19351935            msg_data.msg_body = pj_str(body); 
    19361936 
    1937             status = pjsua_call_send_request(current_call, &SIP_INFO,  
     1937            status = pjsua_call_send_request(current_call, &SIP_INFO, 
    19381938                &msg_data); 
    19391939            if (status != PJ_SUCCESS) { 
     
    19621962        static const pj_str_t err_msg = {"Sorry, need at least one " 
    19631963                                         "account configured\n", 45}; 
    1964         pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen);    
     1964        pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 
    19651965    } else { 
    19661966        char *uri; 
    19671967        char dest[64] = {0}; 
    1968         pj_str_t tmp = pj_str(dest);     
     1968        pj_str_t tmp = pj_str(dest); 
    19691969        struct input_result result; 
    19701970        static const pj_str_t header = {"Send arbitrary request to " 
    19711971                                        "remote host\n", 39}; 
    1972          
    1973         pj_cli_sess_write_msg(cval->sess, header.ptr, header.slen);      
    1974          
    1975         pj_strncpy_with_null(&tmp, &cval->argv[2], sizeof(dest));        
     1972 
     1973        pj_cli_sess_write_msg(cval->sess, header.ptr, header.slen); 
     1974 
     1975        pj_strncpy_with_null(&tmp, &cval->argv[2], sizeof(dest)); 
    19761976        /* Input destination URI */ 
    19771977        uri = NULL; 
    19781978        get_input_url(tmp.ptr, tmp.slen, cval, &result); 
    19791979        if (result.nb_result != PJSUA_APP_NO_NB) { 
    1980             if (result.nb_result == -1) {                
     1980            if (result.nb_result == -1) { 
    19811981                static const pj_str_t err_msg = {"Sorry you can't do that!\n", 
    19821982                                                 26}; 
     
    19951995            } else { 
    19961996                pjsua_buddy_info binfo; 
    1997                 pjsua_buddy_get_info(result.nb_result-1, &binfo);                
     1997                pjsua_buddy_get_info(result.nb_result-1, &binfo); 
    19981998                pj_strncpy_with_null(&tmp, &binfo.uri, sizeof(dest)); 
    19991999                uri = tmp.ptr; 
     
    20072007        if (uri) { 
    20082008            char method[64] = {0}; 
    2009             pj_str_t tmp_method = pj_str(method);            
     2009            pj_str_t tmp_method = pj_str(method); 
    20102010            pj_strncpy_with_null(&tmp_method, &cval->argv[1], sizeof(method)); 
    20112011            tmp = pj_str(uri); 
     
    20162016            * not go well with the call state, so don't do it 
    20172017            * unless it's for testing. 
    2018             */       
     2018            */ 
    20192019            pjsua_call_send_request(current_call, &cval->argv[1], NULL); 
    2020         }     
     2020        } 
    20212021    } 
    20222022    return PJ_SUCCESS; 
     
    20302030                     "You have %d active call%s\n", i, (i>1?"s":"")); 
    20312031 
    2032     pj_cli_sess_write_msg(cval->sess, out_str,  
     2032    pj_cli_sess_write_msg(cval->sess, out_str, 
    20332033        pj_ansi_strlen(out_str)); 
    20342034 
    20352035    if (current_call != PJSUA_INVALID_ID) { 
    20362036        pjsua_call_info ci; 
    2037         if (pjsua_call_get_info(current_call, &ci)==PJ_SUCCESS) {            
    2038             pj_ansi_snprintf(out_str, sizeof(out_str),  
     2037        if (pjsua_call_get_info(current_call, &ci)==PJ_SUCCESS) { 
     2038            pj_ansi_snprintf(out_str, sizeof(out_str), 
    20392039                   "Current call id=%d to %.*s [%.*s]\n", current_call, 
    20402040                   (int)ci.remote_info.slen, ci.remote_info.ptr, 
    20412041                   (int)ci.state_text.slen, ci.state_text.ptr); 
    20422042 
    2043             pj_cli_sess_write_msg(cval->sess, out_str,  
     2043            pj_cli_sess_write_msg(cval->sess, out_str, 
    20442044                                  pj_ansi_strlen(out_str)); 
    20452045        } 
    2046     }  
     2046    } 
    20472047    return PJ_SUCCESS; 
    20482048} 
     
    20502050/* Call handler */ 
    20512051pj_status_t cmd_call_handler(pj_cli_cmd_val *cval) 
    2052 {     
     2052{ 
    20532053    pj_status_t status = PJ_SUCCESS; 
    20542054    pj_cli_cmd_id cmd_id = pj_cli_get_cmd_id(cval->cmd); 
     
    20642064        break; 
    20652065    case CMD_CALL_ANSWER: 
    2066         status = cmd_answer_call(cval);  
    2067         break; 
    2068     case CMD_CALL_HANGUP:        
    2069     case CMD_CALL_HANGUP_ALL:    
     2066        status = cmd_answer_call(cval); 
     2067        break; 
     2068    case CMD_CALL_HANGUP: 
     2069    case CMD_CALL_HANGUP_ALL: 
    20702070        status = cmd_hangup_call(cval, (cmd_id==CMD_CALL_HANGUP_ALL)); 
    20712071        break; 
    2072     case CMD_CALL_HOLD:  
     2072    case CMD_CALL_HOLD: 
    20732073        status = cmd_hold_call(); 
    20742074        break; 
    2075     case CMD_CALL_REINVITE:      
     2075    case CMD_CALL_REINVITE: 
    20762076        status = cmd_call_reinvite(); 
    20772077        break; 
    2078     case CMD_CALL_UPDATE:        
     2078    case CMD_CALL_UPDATE: 
    20792079        status = cmd_call_update(); 
    20802080        break; 
    2081     case CMD_CALL_NEXT:                  
    2082     case CMD_CALL_PREVIOUS:      
    2083         status = cmd_next_call(cmd_id==CMD_CALL_NEXT);   
    2084         break; 
    2085     case CMD_CALL_TRANSFER:      
     2081    case CMD_CALL_NEXT: 
     2082    case CMD_CALL_PREVIOUS: 
     2083        status = cmd_next_call(cmd_id==CMD_CALL_NEXT); 
     2084        break; 
     2085    case CMD_CALL_TRANSFER: 
    20862086        status = cmd_transfer_call(cval); 
    20872087        break; 
    2088     case CMD_CALL_TRANSFER_REPLACE:      
     2088    case CMD_CALL_TRANSFER_REPLACE: 
    20892089        status = cmd_transfer_replace_call(cval); 
    20902090        break; 
     
    20922092        status = cmd_redirect_call(cval); 
    20932093        break; 
    2094     case CMD_CALL_D2833:         
     2094    case CMD_CALL_D2833: 
    20952095        status = cmd_dtmf_2833(cval); 
    20962096        break; 
    2097     case CMD_CALL_INFO:  
     2097    case CMD_CALL_INFO: 
    20982098        status = cmd_call_info(cval); 
    20992099        break; 
    2100     case CMD_CALL_DUMP_Q:        
     2100    case CMD_CALL_DUMP_Q: 
    21012101        status = cmd_call_quality(); 
    21022102        break; 
    2103     case CMD_CALL_SEND_ARB:      
     2103    case CMD_CALL_SEND_ARB: 
    21042104        status = cmd_send_arbitrary(cval); 
    21052105        break; 
     
    21072107        status = cmd_show_current_call(cval); 
    21082108        break; 
    2109     }     
     2109    } 
    21102110 
    21112111    return status; 
    21122112} 
    21132113 
    2114 #if PJSUA_HAS_VIDEO  
     2114#if PJSUA_HAS_VIDEO 
    21152115static pj_status_t cmd_set_video_enable(pj_bool_t enabled) 
    2116 {     
     2116{ 
    21172117    app_config.vid.vid_cnt = (enabled ? 1 : 0); 
    21182118    PJ_LOG(3,(THIS_FILE, "Video will be %s in next offer/answer", 
     
    21362136    pjsua_acc_config acc_cfg; 
    21372137    pj_pool_t *pool = pjsua_pool_create("tmp-pjsua", 1000, 1000); 
    2138      
     2138 
    21392139    pjsua_acc_get_config(current_acc, pool, &acc_cfg); 
    21402140    app_config_show_video(current_acc, &acc_cfg); 
     
    21542154 
    21552155    switch(cmd_id) { 
    2156     case CMD_VIDEO_ACC_AUTORX:   
    2157     case CMD_VIDEO_ACC_AUTOTX:   
     2156    case CMD_VIDEO_ACC_AUTORX: 
     2157    case CMD_VIDEO_ACC_AUTOTX: 
    21582158        { 
    21592159            int on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2)==0); 
    2160          
     2160 
    21612161            if (cmd_id == CMD_VIDEO_ACC_AUTORX) 
    21622162                acc_cfg.vid_in_auto_show = on; 
     
    21652165        } 
    21662166        break; 
    2167     case CMD_VIDEO_ACC_CAP_ID:           
     2167    case CMD_VIDEO_ACC_CAP_ID: 
    21682168    case CMD_VIDEO_ACC_REN_ID: 
    21692169        { 
    2170             int dev = pj_strtol(&cval->argv[1]);                     
     2170            int dev = pj_strtol(&cval->argv[1]); 
    21712171 
    21722172            if (cmd_id == CMD_VIDEO_ACC_CAP_ID) 
    21732173                acc_cfg.vid_cap_dev = dev; 
    2174             else  
    2175                 acc_cfg.vid_rend_dev = dev;              
    2176         }        
     2174            else 
     2175                acc_cfg.vid_rend_dev = dev; 
     2176        } 
    21772177        break; 
    21782178    } 
     
    21902190static pj_status_t cmd_enable_vid_rx(pj_cli_cmd_val *cval) 
    21912191{ 
    2192     pjsua_call_vid_strm_op_param param;     
    2193     pjsua_stream_info si;     
     2192    pjsua_call_vid_strm_op_param param; 
     2193    pjsua_stream_info si; 
    21942194    pj_status_t status = PJ_SUCCESS; 
    21952195    pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0); 
    21962196 
    2197     pjsua_call_vid_strm_op_param_default(&param);     
    2198  
    2199     param.med_idx = pj_strtol(&cval->argv[2]);  
     2197    pjsua_call_vid_strm_op_param_default(&param); 
     2198 
     2199    param.med_idx = pj_strtol(&cval->argv[2]); 
    22002200    if (pjsua_call_get_stream_info(current_call, param.med_idx, &si) || 
    22012201        si.type != PJMEDIA_TYPE_VIDEO) 
     
    22162216static pj_status_t cmd_enable_vid_tx(pj_cli_cmd_val *cval) 
    22172217{ 
    2218     pjsua_call_vid_strm_op_param param;     
     2218    pjsua_call_vid_strm_op_param param; 
    22192219    pj_status_t status = PJ_SUCCESS; 
    2220     pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0);     
    2221      
     2220    pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0); 
     2221 
    22222222    pjsua_call_vid_strm_op op = on? PJSUA_CALL_VID_STRM_START_TRANSMIT : 
    22232223                                PJSUA_CALL_VID_STRM_STOP_TRANSMIT; 
    22242224 
    22252225    pjsua_call_vid_strm_op_param_default(&param); 
    2226      
     2226 
    22272227    param.med_idx = pj_strtol(&cval->argv[2]); 
    22282228 
    2229     status = pjsua_call_set_vid_strm(current_call, op, &param);     
     2229    status = pjsua_call_set_vid_strm(current_call, op, &param); 
    22302230    return status; 
    22312231} 
    22322232 
    2233 static pj_status_t cmd_enable_vid_stream(pj_cli_cmd_val *cval,  
     2233static pj_status_t cmd_enable_vid_stream(pj_cli_cmd_val *cval, 
    22342234                                           pj_bool_t enable) 
    2235 {     
    2236     pjsua_call_vid_strm_op_param param;     
     2235{ 
     2236    pjsua_call_vid_strm_op_param param; 
    22372237    pjsua_call_vid_strm_op op = enable? PJSUA_CALL_VID_STRM_CHANGE_DIR : 
    22382238                                PJSUA_CALL_VID_STRM_REMOVE; 
     
    22422242    param.med_idx = cval->argc > 1 ? pj_strtol(&cval->argv[1]) : -1; 
    22432243    param.dir = PJMEDIA_DIR_ENCODING_DECODING; 
    2244     return pjsua_call_set_vid_strm(current_call, op, &param);     
     2244    return pjsua_call_set_vid_strm(current_call, op, &param); 
    22452245} 
    22462246 
     
    22512251    pjsua_call_vid_strm_op_param_default(&param); 
    22522252    param.med_idx = cval->argc > 1? pj_strtol(&cval->argv[1]) : -1; 
    2253     param.cap_dev = cval->argc > 2? pj_strtol(&cval->argv[2]) :  
     2253    param.cap_dev = cval->argc > 2? pj_strtol(&cval->argv[2]) : 
    22542254                                    PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 
    22552255 
     
    22722272 
    22732273static pj_status_t cmd_vid_device_preview(pj_cli_cmd_val *cval) 
    2274 {         
    2275     int dev_id = pj_strtol(&cval->argv[2]);     
    2276     pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0);           
     2274{ 
     2275    int dev_id = pj_strtol(&cval->argv[2]); 
     2276    pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0); 
    22772277 
    22782278    if (on) { 
     
    22932293            pjsua_vid_preview_stop(dev_id); 
    22942294        } 
    2295     }     
     2295    } 
    22962296    return PJ_SUCCESS; 
    22972297} 
    22982298 
    22992299static pj_status_t cmd_vid_codec_list() 
    2300 {     
     2300{ 
    23012301    pjsua_codec_info ci[PJMEDIA_CODEC_MGR_MAX_CODECS]; 
    23022302    unsigned count = PJ_ARRAY_SIZE(ci); 
     
    23192319            vfd = pjmedia_format_get_video_format_detail(&cp.enc_fmt, 
    23202320                PJ_TRUE); 
    2321             PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f  %4d/%4d  %dx%d",  
     2321            PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f  %4d/%4d  %dx%d", 
    23222322                (int)ci[i].codec_id.slen, ci[i].codec_id.ptr, 
    23232323                13-(int)ci[i].codec_id.slen, "                ", 
     
    23322332 
    23332333static pj_status_t cmd_set_vid_codec_prio(pj_cli_cmd_val *cval) 
    2334 {     
     2334{ 
    23352335    int prio = pj_strtol(&cval->argv[2]); 
    23362336    pj_status_t status; 
    2337          
     2337 
    23382338    status = pjsua_vid_codec_set_priority(&cval->argv[1], (pj_uint8_t)prio); 
    23392339    if (status != PJ_SUCCESS) 
     
    23442344 
    23452345static pj_status_t cmd_set_vid_codec_fps(pj_cli_cmd_val *cval) 
    2346 {     
     2346{ 
    23472347    pjmedia_vid_codec_param cp; 
    2348     int M, N;     
     2348    int M, N; 
    23492349    pj_status_t status; 
    23502350 
     
    23642364 
    23652365static pj_status_t cmd_set_vid_codec_bitrate(pj_cli_cmd_val *cval) 
    2366 {     
    2367     pjmedia_vid_codec_param cp;     
     2366{ 
     2367    pjmedia_vid_codec_param cp; 
    23682368    int M, N; 
    23692369    pj_status_t status; 
     
    23852385static pj_status_t cmd_set_vid_codec_size(pj_cli_cmd_val *cval) 
    23862386{ 
    2387     pjmedia_vid_codec_param cp;     
     2387    pjmedia_vid_codec_param cp; 
    23882388    int M, N; 
    23892389    pj_status_t status; 
     
    24302430 
    24312431static pj_status_t cmd_show_vid_win(pj_cli_cmd_val *cval, pj_bool_t show) 
    2432 {             
     2432{ 
    24332433    pjsua_vid_win_id wid = pj_strtol(&cval->argv[1]); 
    24342434    return pjsua_vid_win_set_show(wid, show); 
     
    24572457/* Video handler */ 
    24582458static pj_status_t cmd_video_handler(pj_cli_cmd_val *cval) 
    2459 {     
     2459{ 
    24602460    pj_status_t status = PJ_SUCCESS; 
    2461     pj_cli_cmd_id cmd_id = pj_cli_get_cmd_id(cval->cmd);     
     2461    pj_cli_cmd_id cmd_id = pj_cli_get_cmd_id(cval->cmd); 
    24622462 
    24632463    CHECK_PJSUA_RUNNING(); 
     
    25252525        status = cmd_arrange_vid_win(); 
    25262526        break; 
    2527     case CMD_VIDEO_WIN_SHOW:     
     2527    case CMD_VIDEO_WIN_SHOW: 
    25282528    case CMD_VIDEO_WIN_HIDE: 
    25292529        status = cmd_show_vid_win(cval, (cmd_id==CMD_VIDEO_WIN_SHOW)); 
     
    25352535        status = cmd_resize_vid_win(cval); 
    25362536        break; 
    2537     }     
     2537    } 
    25382538 
    25392539    return status; 
     
    25432543/* Other command handler */ 
    25442544static pj_status_t cmd_sleep_handler(pj_cli_cmd_val *cval) 
    2545 {     
     2545{ 
    25462546    int delay; 
    25472547 
    25482548    delay = pj_strtoul(&cval->argv[1]); 
    25492549    if (delay < 0) delay = 0; 
    2550     pj_thread_sleep(delay);     
     2550    pj_thread_sleep(delay); 
    25512551 
    25522552    return PJ_SUCCESS; 
     
    25592559 
    25602560    CHECK_PJSUA_RUNNING(); 
    2561      
     2561 
    25622562    status = pjsua_detect_nat_type(); 
    25632563    if (status != PJ_SUCCESS) 
     
    25782578} 
    25792579 
    2580 /*  
    2581  * Syntax error handler for parser.  
     2580/* 
     2581 * Syntax error handler for parser. 
    25822582 */ 
    25832583static void on_syntax_error(pj_scanner *scanner) 
     
    25872587} 
    25882588 
    2589 /*  
     2589/* 
    25902590 * This method will parse buffer string info array of argument string 
    2591  * @argc On input, maximum array size of argument. On output, number of argument  
     2591 * @argc On input, maximum array size of argument. On output, number of argument 
    25922592 * parsed 
    25932593 * @argv Array of argument string 
     
    25982598    pj_scanner scanner; 
    25992599    unsigned max_argc = *argc; 
    2600      
     2600 
    26012601    PJ_USE_EXCEPTION; 
    26022602 
     
    26042604        return PJ_SUCCESS; 
    26052605 
    2606     pj_scan_init(&scanner, options->ptr, options->slen, PJ_SCAN_AUTOSKIP_WS,  
     2606    pj_scan_init(&scanner, options->ptr, options->slen, PJ_SCAN_AUTOSKIP_WS, 
    26072607                 &on_syntax_error); 
    26082608    PJ_TRY { 
     
    26102610        while (!pj_scan_is_eof(&scanner) && (max_argc > *argc)) { 
    26112611            pj_str_t str; 
    2612              
     2612 
    26132613            pj_scan_get_until_chr(&scanner, " \t\r\n", &str); 
    26142614            argv[*argc] = str; 
     
    26172617    } 
    26182618    PJ_CATCH_ANY { 
    2619         pj_scan_fini(&scanner);  
     2619        pj_scan_fini(&scanner); 
    26202620        return PJ_GET_EXCEPTION(); 
    26212621    } 
     
    26362636    pj_cli_quit(cval->sess->fe->cli, cval->sess, PJ_TRUE); 
    26372637 
    2638     /** Get the pjsua option **/        
     2638    /** Get the pjsua option **/ 
    26392639    for (i=1; i < cval->argc; i++) { 
    26402640        pj_str_t argvst[MAX_ARGC]; 
     
    26592659 
    26602660static pj_status_t add_call_command(pj_cli_t *cli) 
    2661 {   
    2662     char* call_command =  
     2661{ 
     2662    char* call_command = 
    26632663        "<CMD name='call' id='100' desc='Call related commands'>" 
    26642664        "  <CMD name='new' id='1001' desc='Make a new call/INVITE'>" 
     
    26992699        "  <CMD name='transfer_replaces' id='1012' sc='X' " 
    27002700        "   desc='Transfer replace call'>" 
    2701         "    <ARG name='call_id' type='choice' id='9911' desc='Call Id'/>"       
     2701        "    <ARG name='call_id' type='choice' id='9911' desc='Call Id'/>" 
    27022702        "  </CMD>" 
    27032703        "  <CMD name='redirect' id='1013' sc='R' desc='Redirect call'>" 
     
    27302730 
    27312731    pj_str_t xml = pj_str(call_command); 
    2732     return pj_cli_add_cmd_from_xml(cli, NULL,  
     2732    return pj_cli_add_cmd_from_xml(cli, NULL, 
    27332733                                   &xml, cmd_call_handler, 
    27342734                                   NULL, get_choice_value); 
     
    27862786    pj_str_t xml = pj_str(presence_command); 
    27872787 
    2788     return pj_cli_add_cmd_from_xml(cli, NULL,  
    2789                                    &xml, cmd_presence_handler,  
     2788    return pj_cli_add_cmd_from_xml(cli, NULL, 
     2789                                   &xml, cmd_presence_handler, 
    27902790                                   NULL, get_choice_value); 
    27912791} 
     
    27932793static pj_status_t add_account_command(pj_cli_t *cli) 
    27942794{ 
    2795     char* account_command =  
     2795    char* account_command = 
    27962796        "<CMD name='acc' id='300' desc='Account commands'>" 
    27972797        "  <CMD name='add' id='3001' sc='+a' desc='Add new account'>" 
     
    28312831 
    28322832    pj_str_t xml = pj_str(account_command); 
    2833     return pj_cli_add_cmd_from_xml(cli, NULL,  
    2834                                    &xml, cmd_account_handler,  
     2833    return pj_cli_add_cmd_from_xml(cli, NULL, 
     2834                                   &xml, cmd_account_handler, 
    28352835                                   NULL, get_choice_value); 
    28362836} 
     
    28382838static pj_status_t add_media_command(pj_cli_t *cli) 
    28392839{ 
    2840     char* media_command =  
     2840    char* media_command = 
    28412841        "<CMD name='audio' id='400' desc='Conference and Media commands'>" 
    28422842        "  <CMD name='list' id='4001' sc='cl' desc='Show conference list'/>" 
     
    28662866 
    28672867    pj_str_t xml = pj_str(media_command); 
    2868     return pj_cli_add_cmd_from_xml(cli, NULL,  
    2869                                    &xml, cmd_media_handler,  
     2868    return pj_cli_add_cmd_from_xml(cli, NULL, 
     2869                                   &xml, cmd_media_handler, 
    28702870                                   NULL, get_choice_value); 
    28712871} 
     
    28732873static pj_status_t add_config_command(pj_cli_t *cli) 
    28742874{ 
    2875     char* config_command =  
     2875    char* config_command = 
    28762876        "<CMD name='stat' id='500' desc='Status and config commands'>" 
    28772877        "  <CMD name='dump_stat' id='5001' sc='ds' desc='Dump status'/>" 
     
    28872887 
    28882888    pj_str_t xml = pj_str(config_command); 
    2889     return pj_cli_add_cmd_from_xml(cli, NULL,  
     2889    return pj_cli_add_cmd_from_xml(cli, NULL, 
    28902890                                   &xml, cmd_config_handler, 
    28912891                                   NULL, get_choice_value); 
    28922892} 
    28932893 
    2894 #if PJSUA_HAS_VIDEO     
     2894#if PJSUA_HAS_VIDEO 
    28952895static pj_status_t add_video_command(pj_cli_t *cli) 
    28962896{ 
     
    30323032 
    30333033    pj_str_t xml = pj_str(video_command); 
    3034     return pj_cli_add_cmd_from_xml(cli, NULL,  
    3035                                    &xml, cmd_video_handler,  
     3034    return pj_cli_add_cmd_from_xml(cli, NULL, 
     3035                                   &xml, cmd_video_handler, 
    30363036                                   NULL, get_choice_value); 
    30373037} 
     
    30603060 
    30613061    pj_status_t status; 
    3062     pj_str_t sleep_xml = pj_str(sleep_command);     
     3062    pj_str_t sleep_xml = pj_str(sleep_command); 
    30633063    pj_str_t network_xml = pj_str(network_command); 
    30643064    pj_str_t shutdown_xml = pj_str(shutdown_command); 
    30653065    pj_str_t restart_xml = pj_str(restart_command); 
    30663066 
    3067     status = pj_cli_add_cmd_from_xml(cli, NULL,  
    3068                                      &sleep_xml, cmd_sleep_handler,  
     3067    status = pj_cli_add_cmd_from_xml(cli, NULL, 
     3068                                     &sleep_xml, cmd_sleep_handler, 
    30693069                                     NULL, NULL); 
    30703070    if (status != PJ_SUCCESS) 
    30713071        return status; 
    30723072 
    3073     status = pj_cli_add_cmd_from_xml(cli, NULL,  
    3074                                      &network_xml, cmd_network_handler,  
     3073    status = pj_cli_add_cmd_from_xml(cli, NULL, 
     3074                                     &network_xml, cmd_network_handler, 
    30753075                                     NULL, NULL); 
    30763076    if (status != PJ_SUCCESS) 
    30773077        return status; 
    30783078 
    3079     status = pj_cli_add_cmd_from_xml(cli, NULL,  
    3080                                      &shutdown_xml, cmd_quit_handler,  
     3079    status = pj_cli_add_cmd_from_xml(cli, NULL, 
     3080                                     &shutdown_xml, cmd_quit_handler, 
    30813081                                     NULL, NULL); 
    30823082 
     
    30843084        return status; 
    30853085 
    3086     status = pj_cli_add_cmd_from_xml(cli, NULL,  
    3087                                      &restart_xml, cmd_restart_handler,  
     3086    status = pj_cli_add_cmd_from_xml(cli, NULL, 
     3087                                     &restart_xml, cmd_restart_handler, 
    30883088                                     NULL, NULL); 
    30893089 
     
    31153115        return status; 
    31163116 
    3117 #if PJSUA_HAS_VIDEO     
     3117#if PJSUA_HAS_VIDEO 
    31183118    status = add_video_command(cli); 
    31193119    if (status != PJ_SUCCESS) 
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_config.c

    r4714 r4729  
    11/* $Id$ */ 
    2 /*  
     2/* 
    33 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    44 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
     
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919 */ 
    2020#include "pjsua_app_common.h" 
     
    219219 * Read command arguments from config file. 
    220220 */ 
    221 static int read_config_file(pj_pool_t *pool, const char *filename,  
     221static int read_config_file(pj_pool_t *pool, const char *filename, 
    222222                            int *app_argc, char ***app_argv) 
    223223{ 
     
    249249        pj_size_t   len; 
    250250        int token_len; 
    251          
     251 
    252252        pj_bzero(line, sizeof(line)); 
    253253        if (fgets(line, sizeof(line), fhnd) == NULL) break; 
    254          
     254 
    255255        // Trim ending newlines 
    256256        len = strlen(line); 
     
    268268            if (*p == '\0')                 // are we done yet? 
    269269                break; 
    270              
     270 
    271271            if (*p == '"' || *p == '\'') {    // is token a quoted string 
    272272                cDelimiter = *p++;          // save quote delimiter 
    273273                token = p; 
    274                  
     274 
    275275                while (*p != '\0' && *p != cDelimiter) p++; 
    276                  
     276 
    277277                if (*p == '\0')         // found end of the line, but, 
    278278                    cDelimiter = '\0';  // didn't find a matching quote 
     
    280280            } else {                    // token's not a quoted string 
    281281                token = p; 
    282                  
     282 
    283283                while (*p != '\0' && strchr(whitespace, *p) == NULL) p++; 
    284                  
     284 
    285285                cDelimiter = *p; 
    286286            } 
    287              
     287 
    288288            *p = '\0'; 
    289289            token_len = (int)(p-token); 
    290              
     290 
    291291            if (token_len > 0) { 
    292292                if (*token == '#') 
    293293                    break;  // ignore remainder of line 
    294                  
     294 
    295295                argv[argc] = pj_pool_alloc(pool, token_len + 1); 
    296296                pj_memcpy(argv[argc], token, token_len + 1); 
    297297                ++argc; 
    298298            } 
    299              
     299 
    300300            *p = cDelimiter; 
    301301        } 
     
    307307 
    308308    if (argc == MAX_ARGS && (i!=*app_argc || !feof(fhnd))) { 
    309         PJ_LOG(1,(THIS_FILE,  
     309        PJ_LOG(1,(THIS_FILE, 
    310310                  "Too many arguments specified in cmd line/config file")); 
    311311        fflush(stdout); 
     
    323323 
    324324/* Parse arguments. */ 
    325 static pj_status_t parse_args(int argc, char *argv[],                          
     325static pj_status_t parse_args(int argc, char *argv[], 
    326326                              pj_str_t *uri_to_call) 
    327327{ 
     
    329329    int option_index; 
    330330    pjsua_app_config *cfg = &app_config; 
    331     enum { OPT_CONFIG_FILE=127, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL,  
     331    enum { OPT_CONFIG_FILE=127, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL, 
    332332           OPT_LOG_APPEND, OPT_COLOR, OPT_NO_COLOR, OPT_LIGHT_BG, OPT_NO_STDERR, 
    333333           OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, OPT_SND_AUTO_CLOSE, 
    334            OPT_LOCAL_PORT, OPT_IP_ADDR, OPT_PROXY, OPT_OUTBOUND_PROXY,  
     334           OPT_LOCAL_PORT, OPT_IP_ADDR, OPT_PROXY, OPT_OUTBOUND_PROXY, 
    335335           OPT_REGISTRAR, OPT_REG_TIMEOUT, OPT_PUBLISH, OPT_ID, OPT_CONTACT, 
    336336           OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS, 
     
    342342           OPT_AUTO_CONF, OPT_CLOCK_RATE, OPT_SND_CLOCK_RATE, OPT_STEREO, 
    343343           OPT_USE_ICE, OPT_ICE_REGULAR, OPT_USE_SRTP, OPT_SRTP_SECURE, 
    344            OPT_USE_TURN, OPT_ICE_MAX_HOSTS, OPT_ICE_NO_RTCP, OPT_TURN_SRV,  
     344           OPT_USE_TURN, OPT_ICE_MAX_HOSTS, OPT_ICE_NO_RTCP, OPT_TURN_SRV, 
    345345           OPT_TURN_TCP, OPT_TURN_USER, OPT_TURN_PASSWD, 
    346            OPT_PLAY_FILE, OPT_PLAY_TONE, OPT_RTP_PORT, OPT_ADD_CODEC,  
     346           OPT_PLAY_FILE, OPT_PLAY_TONE, OPT_RTP_PORT, OPT_ADD_CODEC, 
    347347           OPT_ILBC_MODE, OPT_REC_FILE, OPT_AUTO_REC, 
    348348           OPT_COMPLEXITY, OPT_QUALITY, OPT_PTIME, OPT_NO_VAD, 
    349349           OPT_RX_DROP_PCT, OPT_TX_DROP_PCT, OPT_EC_TAIL, OPT_EC_OPT, 
    350            OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS,  
     350           OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 
    351351           OPT_DURATION, OPT_NO_TCP, OPT_NO_UDP, OPT_THREAD_CNT, 
    352352           OPT_NOREFERSUB, OPT_ACCEPT_REDIRECT, 
     
    458458        { "thread-cnt", 1, 0, OPT_THREAD_CNT}, 
    459459#if defined(PJSIP_HAS_TLS_TRANSPORT) && (PJSIP_HAS_TLS_TRANSPORT != 0) 
    460         { "use-tls",    0, 0, OPT_USE_TLS},  
     460        { "use-tls",    0, 0, OPT_USE_TLS}, 
    461461        { "tls-ca-file",1, 0, OPT_TLS_CA_FILE}, 
    462         { "tls-cert-file",1,0, OPT_TLS_CERT_FILE},  
     462        { "tls-cert-file",1,0, OPT_TLS_CERT_FILE}, 
    463463        { "tls-privkey-file",1,0, OPT_TLS_PRIV_FILE}, 
    464464        { "tls-password",1,0, OPT_TLS_PASSWORD}, 
     
    504504    unsigned i; 
    505505 
    506     /* Run pj_getopt once to see if user specifies config file to read. */  
     506    /* Run pj_getopt once to see if user specifies config file to read. */ 
    507507    pj_optind = 0; 
    508     while ((c=pj_getopt_long(argc, argv, "", long_options,  
    509                              &option_index)) != -1)  
     508    while ((c=pj_getopt_long(argc, argv, "", long_options, 
     509                             &option_index)) != -1) 
    510510    { 
    511511        switch (c) { 
     
    541541            /* Ignore as this has been processed before */ 
    542542            break; 
    543          
     543 
    544544        case OPT_LOG_FILE: 
    545545            cfg->log_cfg.log_filename = pj_str(pj_optarg); 
     
    549549            c = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    550550            if (c < 0 || c > 6) { 
    551                 PJ_LOG(1,(THIS_FILE,  
     551                PJ_LOG(1,(THIS_FILE, 
    552552                          "Error: expecting integer value 0-6 " 
    553553                          "for --log-level")); 
     
    560560        case OPT_APP_LOG_LEVEL: 
    561561            cfg->log_cfg.console_level = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    562             if (cfg->log_cfg.console_level < 0 || cfg->log_cfg.console_level > 6) { 
    563                 PJ_LOG(1,(THIS_FILE,  
     562            if (cfg->log_cfg.console_level > 6) { 
     563                PJ_LOG(1,(THIS_FILE, 
    564564                          "Error: expecting integer value 0-6 " 
    565565                          "for --app-log-level")); 
     
    614614                return PJ_EINVAL; 
    615615            } 
    616             cfg->media_cfg.clock_rate = lval;  
     616            cfg->media_cfg.clock_rate = lval; 
    617617            break; 
    618618 
     
    624624                return PJ_EINVAL; 
    625625            } 
    626             cfg->media_cfg.snd_clock_rate = lval;  
     626            cfg->media_cfg.snd_clock_rate = lval; 
    627627            break; 
    628628 
     
    634634            lval = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    635635            if (lval < 0 || lval > 65535) { 
    636                 PJ_LOG(1,(THIS_FILE,  
     636                PJ_LOG(1,(THIS_FILE, 
    637637                          "Error: expecting integer value for " 
    638638                          "--local-port")); 
     
    676676        case OPT_PROXY:   /* proxy */ 
    677677            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
    678                 PJ_LOG(1,(THIS_FILE,  
     678                PJ_LOG(1,(THIS_FILE, 
    679679                          "Error: invalid SIP URL '%s' " 
    680680                          "in proxy argument", pj_optarg)); 
     
    686686        case OPT_OUTBOUND_PROXY:   /* outbound proxy */ 
    687687            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
    688                 PJ_LOG(1,(THIS_FILE,  
     688                PJ_LOG(1,(THIS_FILE, 
    689689                          "Error: invalid SIP URL '%s' " 
    690690                          "in outbound proxy argument", pj_optarg)); 
     
    696696        case OPT_REGISTRAR:   /* registrar */ 
    697697            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
    698                 PJ_LOG(1,(THIS_FILE,  
     698                PJ_LOG(1,(THIS_FILE, 
    699699                          "Error: invalid SIP URL '%s' in " 
    700700                          "registrar argument", pj_optarg)); 
     
    707707            cur_acc->reg_timeout = pj_strtoul(pj_cstr(&tmp,pj_optarg)); 
    708708            if (cur_acc->reg_timeout < 1 || cur_acc->reg_timeout > 3600) { 
    709                 PJ_LOG(1,(THIS_FILE,  
     709                PJ_LOG(1,(THIS_FILE, 
    710710                          "Error: invalid value for --reg-timeout " 
    711711                          "(expecting 1-3600)")); 
     
    730730            lval = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    731731            if (lval < 0 || lval > 3) { 
    732                 PJ_LOG(1,(THIS_FILE,  
     732                PJ_LOG(1,(THIS_FILE, 
    733733                          "Error: expecting integer value 0-3 for --use-timer")); 
    734734                return PJ_EINVAL; 
     
    741741            cur_acc->timer_setting.sess_expires = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    742742            if (cur_acc->timer_setting.sess_expires < 90) { 
    743                 PJ_LOG(1,(THIS_FILE,  
     743                PJ_LOG(1,(THIS_FILE, 
    744744                          "Error: invalid value for --timer-se " 
    745745                          "(expecting higher than 90)")); 
     
    752752            cur_acc->timer_setting.min_se = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    753753            if (cur_acc->timer_setting.min_se < 90) { 
    754                 PJ_LOG(1,(THIS_FILE,  
     754                PJ_LOG(1,(THIS_FILE, 
    755755                          "Error: invalid value for --timer-min-se " 
    756756                          "(expecting higher than 90)")); 
     
    770770        case OPT_ID:   /* id */ 
    771771            if (pjsua_verify_url(pj_optarg) != 0) { 
    772                 PJ_LOG(1,(THIS_FILE,  
     772                PJ_LOG(1,(THIS_FILE, 
    773773                          "Error: invalid SIP URL '%s' " 
    774774                          "in local id argument", pj_optarg)); 
     
    780780        case OPT_CONTACT:   /* contact */ 
    781781            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
    782                 PJ_LOG(1,(THIS_FILE,  
     782                PJ_LOG(1,(THIS_FILE, 
    783783                          "Error: invalid SIP URL '%s' " 
    784784                          "in contact argument", pj_optarg)); 
     
    822822        case OPT_ACCEPT_REDIRECT: 
    823823            cfg->redir_op = my_atoi(pj_optarg); 
    824             if (cfg->redir_op<0 || cfg->redir_op>PJSIP_REDIRECT_STOP) { 
    825                 PJ_LOG(1,(THIS_FILE,  
     824            if (cfg->redir_op>PJSIP_REDIRECT_STOP) { 
     825                PJ_LOG(1,(THIS_FILE, 
    826826                          "Error: accept-redirect value '%s' ", pj_optarg)); 
    827827                return PJ_EINVAL; 
     
    893893        case OPT_ADD_BUDDY: /* Add to buddy list. */ 
    894894            if (pjsua_verify_url(pj_optarg) != 0) { 
    895                 PJ_LOG(1,(THIS_FILE,  
     895                PJ_LOG(1,(THIS_FILE, 
    896896                          "Error: invalid URL '%s' in " 
    897897                          "--add-buddy option", pj_optarg)); 
     
    899899            } 
    900900            if (cfg->buddy_cnt == PJ_ARRAY_SIZE(cfg->buddy_cfg)) { 
    901                 PJ_LOG(1,(THIS_FILE,  
     901                PJ_LOG(1,(THIS_FILE, 
    902902                          "Error: too many buddies in buddy list.")); 
    903903                return -1; 
     
    10221022        case OPT_SRTP_SECURE: 
    10231023            app_config.cfg.srtp_secure_signaling = my_atoi(pj_optarg); 
    1024             if (!pj_isdigit(*pj_optarg) ||  
    1025                 app_config.cfg.srtp_secure_signaling > 2)  
     1024            if (!pj_isdigit(*pj_optarg) || 
     1025                app_config.cfg.srtp_secure_signaling > 2) 
    10261026            { 
    10271027                PJ_LOG(1,(THIS_FILE, "Invalid value for --srtp-secure option")); 
     
    10391039 
    10401040                range = (65535-START_PORT-PJSUA_MAX_CALLS*2); 
    1041                 cfg->rtp_cfg.port = START_PORT +  
     1041                cfg->rtp_cfg.port = START_PORT + 
    10421042                                    ((pj_rand() % range) & 0xFFFE); 
    10431043            } 
     
    11121112        case OPT_QUALITY: 
    11131113            cfg->media_cfg.quality = my_atoi(pj_optarg); 
    1114             if (cfg->media_cfg.quality < 0 || cfg->media_cfg.quality > 10) { 
     1114            if (cfg->media_cfg.quality > 10) { 
    11151115                PJ_LOG(1,(THIS_FILE, 
    11161116                          "Error: invalid --quality (expecting 0-10")); 
     
    11361136            } 
    11371137            break; 
    1138              
     1138 
    11391139        case OPT_TX_DROP_PCT: 
    11401140            cfg->media_cfg.tx_drop_pct = my_atoi(pj_optarg); 
     
    11701170            cfg->use_tls = PJ_TRUE; 
    11711171            break; 
    1172              
     1172 
    11731173        case OPT_TLS_CA_FILE: 
    11741174            cfg->udp_cfg.tls_setting.ca_list_file = pj_str(pj_optarg); 
    11751175            break; 
    1176              
     1176 
    11771177        case OPT_TLS_CERT_FILE: 
    11781178            cfg->udp_cfg.tls_setting.cert_file = pj_str(pj_optarg); 
    11791179            break; 
    1180              
     1180 
    11811181        case OPT_TLS_PRIV_FILE: 
    11821182            cfg->udp_cfg.tls_setting.privkey_file = pj_str(pj_optarg); 
     
    12221222                    ciphers_cnt = PJ_ARRAY_SIZE(ciphers); 
    12231223                    pj_ssl_cipher_get_availables(ciphers, &ciphers_cnt); 
    1224                      
     1224 
    12251225                    PJ_LOG(1,(THIS_FILE, "Cipher \"%s\" is not supported by " 
    12261226                                         "TLS/SSL backend.", pj_optarg)); 
     
    12861286            cfg->rtp_cfg.qos_type = PJ_QOS_TYPE_VOICE; 
    12871287            /* Directly apply DSCP value to SIP traffic. Say lets 
    1288              * set it to CS3 (DSCP 011000). Note that this will not  
     1288             * set it to CS3 (DSCP 011000). Note that this will not 
    12891289             * work on all platforms. 
    12901290             */ 
     
    13371337 
    13381338        default: 
    1339             PJ_LOG(1,(THIS_FILE,  
     1339            PJ_LOG(1,(THIS_FILE, 
    13401340                      "Argument \"%s\" is not valid. Use --help to see help", 
    13411341                      argv[pj_optind-1])); 
     
    14021402            /* Realm must point to the real domain */ 
    14031403            if (*acfg->cred_info[0].realm.ptr=='*') { 
    1404                 PJ_LOG(1,(THIS_FILE,  
     1404                PJ_LOG(1,(THIS_FILE, 
    14051405                          "Error: cannot use '*' as realm with IMS")); 
    14061406                return PJ_EINVAL; 
     
    14091409            /* Username for authentication must be in a@b format */ 
    14101410            if (strchr(acfg->cred_info[0].username.ptr, '@')==0) { 
    1411                 PJ_LOG(1,(THIS_FILE,  
     1411                PJ_LOG(1,(THIS_FILE, 
    14121412                          "Error: Username for authentication must " 
    14131413                          "be in user@domain format with IMS")); 
     
    14561456    for (i=0; i<PJ_ARRAY_SIZE(cfg->buddy_cfg); ++i) 
    14571457        pjsua_buddy_config_default(&cfg->buddy_cfg[i]); 
    1458      
     1458 
    14591459    cfg->vid.vcapture_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 
    14601460    cfg->vid.vrender_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV; 
     
    15001500        return status; 
    15011501 
    1502     if (app_running) {     
     1502    if (app_running) { 
    15031503        app_config.use_cli = use_cli; 
    15041504        app_config.cli_cfg.cli_fe = cli_fe; 
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_legacy.c

    r4724 r4729  
    11/* $Id$ */ 
    2 /*  
     2/* 
    33 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    44 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
     
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919 */ 
    2020 
     
    4848                continue; 
    4949 
    50             printf(" [%2d] <%.*s>  %.*s\n",  
    51                     ids[i]+1,  
     50            printf(" [%2d] <%.*s>  %.*s\n", 
     51                    ids[i]+1, 
    5252                    (int)info.status_text.slen, 
    53                     info.status_text.ptr,  
     53                    info.status_text.ptr, 
    5454                    (int)info.uri.slen, 
    5555                    info.uri.ptr); 
     
    6262 * Input URL. 
    6363 */ 
    64 static void ui_input_url(const char *title, char *buf, pj_size_t len,  
     64static void ui_input_url(const char *title, char *buf, pj_size_t len, 
    6565                         input_result *result) 
    6666{ 
     
    9898 
    9999    if (pj_isdigit(*buf) || *buf=='-') { 
    100          
     100 
    101101        unsigned i; 
    102          
     102 
    103103        if (*buf=='-') 
    104104            i = 1; 
     
    115115        result->nb_result = my_atoi(buf); 
    116116 
    117         if (result->nb_result >= 0 &&  
    118             result->nb_result <= (int)pjsua_get_buddy_count())  
     117        if (result->nb_result >= 0 && 
     118            result->nb_result <= (int)pjsua_get_buddy_count()) 
    119119        { 
    120120            return; 
     
    155155    if (!*buf) 
    156156        return PJ_FALSE; 
    157      
     157 
    158158    return PJ_TRUE; 
    159159} 
     
    170170 
    171171    if (!info.has_registration) { 
    172         pj_ansi_snprintf(buf, sizeof(buf), "%.*s",  
     172        pj_ansi_snprintf(buf, sizeof(buf), "%.*s", 
    173173                         (int)info.status_text.slen, 
    174174                         info.status_text.ptr); 
     
    186186    printf(" %c[%2d] %.*s: %s\n", (acc_id==current_acc?'*':' '), 
    187187           acc_id,  (int)info.acc_uri.slen, info.acc_uri.ptr, buf); 
    188     printf("       Online status: %.*s\n",  
     188    printf("       Online status: %.*s\n", 
    189189        (int)info.online_status_text.slen, 
    190190        info.online_status_text.ptr); 
     
    209209 
    210210    print_buddy_list(); 
    211      
     211 
    212212    //puts("Commands:"); 
    213213    puts("+=============================================================================+"); 
     
    386386                                             PJSUA_CALL_VID_STRM_ADD, NULL); 
    387387        } 
    388         else if (argc >= 3 &&  
     388        else if (argc >= 3 && 
    389389                 (strcmp(argv[2], "disable")==0 || strcmp(argv[2], "enable")==0)) 
    390390        { 
     
    514514                    vfd = pjmedia_format_get_video_format_detail(&cp.enc_fmt, 
    515515                                                                 PJ_TRUE); 
    516                     PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f  %4d/%4d  %dx%d",  
     516                    PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f  %4d/%4d  %dx%d", 
    517517                              (int)ci[i].codec_id.slen, ci[i].codec_id.ptr, 
    518518                              13-(int)ci[i].codec_id.slen, "                ", 
     
    591591/** UI Command **/ 
    592592static void ui_make_new_call() 
    593 {     
     593{ 
    594594    char buf[128]; 
    595595    pjsua_msg_data msg_data; 
     
    598598 
    599599    printf("(You currently have %d calls)\n", pjsua_call_get_count()); 
    600      
     600 
    601601    ui_input_url("Make call", buf, sizeof(buf), &result); 
    602602    if (result.nb_result != PJSUA_APP_NO_NB) { 
     
    620620    pjsua_msg_data_init(&msg_data); 
    621621    TEST_MULTIPART(&msg_data); 
    622     pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL,  
     622    pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, 
    623623                         &msg_data, &current_call); 
    624624} 
     
    754754    } 
    755755 
    756     if (current_call == -1 ||  
     756    if (current_call == -1 || 
    757757        call_info.role != PJSIP_ROLE_UAS || 
    758758        call_info.state >= PJSIP_INV_STATE_CONNECTING) 
     
    779779 
    780780        if (st_code/100 == 3) { 
    781             if (!simple_input("Enter URL to be put in Contact",  
     781            if (!simple_input("Enter URL to be put in Contact", 
    782782                contact, sizeof(contact))) 
    783783                return; 
     
    790790        /* 
    791791        * Must check again! 
    792         * Call may have been disconnected while we're waiting for  
     792        * Call may have been disconnected while we're waiting for 
    793793        * keyboard input. 
    794794        */ 
     
    800800 
    801801        pjsua_call_answer2(current_call, &call_opt, st_code, NULL, &msg_data); 
    802     }     
     802    } 
    803803} 
    804804 
     
    832832 
    833833        pjsua_call_get_info(current_call, &call_info); 
    834         PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s",  
    835             (int)call_info.remote_info.slen,  
     834        PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s", 
     835            (int)call_info.remote_info.slen, 
    836836            call_info.remote_info.ptr)); 
    837837 
     
    912912    acc_cfg.cred_info[0].data = pj_str(passwd); 
    913913 
    914     acc_cfg.rtp_cfg = *rtp_cfg;     
     914    acc_cfg.rtp_cfg = *rtp_cfg; 
    915915    app_config_init_video(&acc_cfg); 
    916916 
     
    959959static void ui_call_hold() 
    960960{ 
    961     if (current_call != -1) {            
     961    if (current_call != -1) { 
    962962        pjsua_call_set_hold(current_call, NULL); 
    963963    } else { 
     
    974974static void ui_send_update() 
    975975{ 
    976     if (current_call != -1) {            
     976    if (current_call != -1) { 
    977977        pjsua_call_update2(current_call, &call_opt, NULL); 
    978978    } else { 
     
    10371037 
    10381038    new_prio = atoi(prio); 
    1039     if (new_prio < 0)  
     1039    if (new_prio < 0) 
    10401040        new_prio = 0; 
    1041     else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST)  
     1041    else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST) 
    10421042        new_prio = PJMEDIA_CODEC_PRIO_HIGHEST; 
    10431043 
    1044     status = pjsua_codec_set_priority(pj_cstr(&id, codec),  
     1044    status = pjsua_codec_set_priority(pj_cstr(&id, codec), 
    10451045                                      (pj_uint8_t)new_prio); 
    10461046#if PJSUA_HAS_VIDEO 
    10471047    if (status != PJ_SUCCESS) { 
    1048         status = pjsua_vid_codec_set_priority(pj_cstr(&id, codec),  
     1048        status = pjsua_vid_codec_set_priority(pj_cstr(&id, codec), 
    10491049                                              (pj_uint8_t)new_prio); 
    10501050    } 
     
    11061106 
    11071107static void ui_call_transfer_replaces(pj_bool_t no_refersub) 
    1108 {         
     1108{ 
    11091109    if (current_call == -1) { 
    11101110        PJ_LOG(3,(THIS_FILE, "No current call")); 
     
    11791179        if (no_refersub) { 
    11801180            /* Add Refer-Sub: false in outgoing REFER request */ 
    1181             pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB,  
     1181            pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, 
    11821182                                           &STR_FALSE); 
    11831183            pj_list_push_back(&msg_data.hdr_list, &refer_sub); 
    11841184        } 
    11851185 
    1186         pjsua_call_xfer_replaces(call, dst_call,  
    1187                                  PJSUA_XFER_NO_REQUIRE_REPLACES,  
     1186        pjsua_call_xfer_replaces(call, dst_call, 
     1187                                 PJSUA_XFER_NO_REQUIRE_REPLACES, 
    11881188                                 &msg_data); 
    11891189    } 
     
    12021202        char buf[128]; 
    12031203 
    1204         if (!simple_input("DTMF strings to send (0-9*#A-B)", buf,  
     1204        if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, 
    12051205            sizeof(buf))) 
    12061206        { 
     
    12351235        char buf[128]; 
    12361236 
    1237         if (!simple_input("DTMF strings to send (0-9*#A-B)", buf,  
     1237        if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, 
    12381238            sizeof(buf))) 
    12391239        { 
     
    12601260            msg_data.msg_body = pj_str(body); 
    12611261 
    1262             status = pjsua_call_send_request(current_call, &SIP_INFO,  
     1262            status = pjsua_call_send_request(current_call, &SIP_INFO, 
    12631263                &msg_data); 
    12641264            if (status != PJ_SUCCESS) { 
     
    13021302                return; 
    13031303            } 
    1304         } else {             
     1304        } else { 
    13051305            pjsua_buddy_info binfo; 
    13061306            pjsua_buddy_get_info(result.nb_result-1, &binfo); 
     
    13271327        pj_str_t method = pj_str(text); 
    13281328        pjsua_call_send_request(current_call, &method, NULL); 
    1329     }        
     1329    } 
    13301330} 
    13311331 
     
    13621362        delay = pj_strtoul(&tmp); 
    13631363        if (delay < 0) delay = 0; 
    1364         pj_thread_sleep(delay);          
     1364        pj_thread_sleep(delay); 
    13651365    } 
    13661366} 
     
    14291429    pj_bool_t online_status; 
    14301430    pjrpid_element elem; 
    1431     int i, choice; 
     1431    int choice; 
     1432    unsigned i; 
    14321433 
    14331434    enum { 
     
    14501451    printf("\n" 
    14511452           "Choices:\n"); 
    1452     for (i=0; i<PJ_ARRAY_SIZE(opts); ++i) { 
     1453    for (i=0; i<(unsigned)PJ_ARRAY_SIZE(opts); ++i) { 
    14531454        printf("  %d  %s\n", opts[i].id+1, opts[i].name); 
    14541455    } 
     
    15251526            pj_ansi_strcat(txlist, s); 
    15261527        } 
    1527         printf("Port #%02d[%2dKHz/%dms/%d] %20.*s  transmitting to: %s\n",  
    1528                info.slot_id,  
     1528        printf("Port #%02d[%2dKHz/%dms/%d] %20.*s  transmitting to: %s\n", 
     1529               info.slot_id, 
    15291530               info.clock_rate/1000, 
    15301531               info.samples_per_frame*1000/info.channel_count/info.clock_rate, 
    15311532               info.channel_count, 
    1532                (int)info.name.slen,  
     1533               (int)info.name.slen, 
    15331534               info.name.ptr, 
    15341535               txlist); 
     
    16091610        PJ_LOG(1,(THIS_FILE, "Error: not enough buffer")); 
    16101611    else 
    1611         PJ_LOG(3,(THIS_FILE, "Dumping configuration (%d bytes):\n%s\n",  
    1612                   len, settings));       
     1612        PJ_LOG(3,(THIS_FILE, "Dumping configuration (%d bytes):\n%s\n", 
     1613                  len, settings)); 
    16131614} 
    16141615 
     
    16551656            PJ_LOG(1,(THIS_FILE, "Call %d has gone", current_call)); 
    16561657        } else if (menuin[1] == 'a') { 
    1657             pjsua_call_process_redirect(current_call,  
     1658            pjsua_call_process_redirect(current_call, 
    16581659                PJSIP_REDIRECT_ACCEPT_REPLACE); 
    16591660        } else if (menuin[1] == 'A') { 
    1660             pjsua_call_process_redirect(current_call,  
     1661            pjsua_call_process_redirect(current_call, 
    16611662                PJSIP_REDIRECT_ACCEPT); 
    16621663        } else if (menuin[1] == 'r') { 
     
    16741675 */ 
    16751676void legacy_main() 
    1676 {     
    1677     char menuin[80];     
    1678     char buf[128];     
     1677{ 
     1678    char menuin[80]; 
     1679    char buf[128]; 
    16791680 
    16801681    keystroke_help(); 
     
    16861687 
    16871688        if (fgets(menuin, sizeof(menuin), stdin) == NULL) { 
    1688             /*  
     1689            /* 
    16891690             * Be friendly to users who redirect commands into 
    16901691             * program, when file ends, resume with kbd. 
     
    17861787            break; 
    17871788 
    1788         case 'v':            
     1789        case 'v': 
    17891790#if PJSUA_HAS_VIDEO 
    17901791            if (menuin[1]=='i' && menuin[2]=='d' && menuin[3]==' ') { 
     
    18691870            ui_register(menuin); 
    18701871            break; 
    1871              
     1872 
    18721873        case 't': 
    18731874            ui_toggle_state(); 
     
    18911892 
    18921893        case 'V': 
    1893             /* Adjust audio volume */        
     1894            /* Adjust audio volume */ 
    18941895            ui_adjust_volume(); 
    18951896            break; 
     
    18971898        case 'd': 
    18981899            if (menuin[1] == 'c') { 
    1899                 ui_dump_configuration();         
     1900                ui_dump_configuration(); 
    19001901            } else if (menuin[1] == 'q') { 
    19011902                ui_dump_call_quality(); 
    1902             } else {             
     1903            } else { 
    19031904                ui_app_dump(menuin[1]=='d'); 
    19041905            } 
     
    19071908        case 'f': 
    19081909            if (simple_input("Enter output filename", buf, sizeof(buf))) { 
    1909                 ui_write_settings();             
     1910                ui_write_settings(); 
    19101911            } 
    19111912            break; 
     
    19161917            goto on_exit; 
    19171918 
    1918         case 'R':            
     1919        case 'R': 
    19191920            ui_call_redirect(menuin); 
    19201921            break; 
Note: See TracChangeset for help on using the changeset viewer.