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

Misc (re #1630): fix gcc warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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; 
Note: See TracChangeset for help on using the changeset viewer.