Changeset 300 for pjproject


Ignore:
Timestamp:
Mar 6, 2006 3:14:59 PM (19 years ago)
Author:
bennylp
Message:

Renamed getopt() to pj_getopt(), and fixed misc Linux warnings

Location:
pjproject/trunk/pjsip
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/build/Makefile

    r296 r300  
    7171export PJSUA_LIB_SRCDIR = ../src/pjsua-lib 
    7272export PJSUA_LIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 
    73                         pjsua_call.o pjsua_core.o pjsua_im.o pjsua_pres.o pjsua_reg.o \ 
    74                         pjsua_settings.o \ 
     73                        getopt.o pjsua_call.o pjsua_core.o pjsua_im.o \ 
     74                        pjsua_pres.o pjsua_reg.o pjsua_settings.o \ 
    7575                         
    7676export PJSUA_LIB_CFLAGS += $(_CFLAGS) 
  • pjproject/trunk/pjsip/include/pjsua-lib/getopt.h

    r238 r300  
    11/* $Id$ */ 
    22/* This file has now become GPL. */ 
    3 /* Declarations for getopt. 
     3/* Declarations for pj_getopt. 
    44   Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. 
    55   This file is part of the GNU C Library. 
     
    2020   Boston, MA 02111-1307, USA.  */ 
    2121 
    22 #ifndef _GETOPT_H 
    23 #define _GETOPT_H 1 
     22#ifndef __PJ_GETOPT_H__ 
     23#define __PJ_GETOPT_H__ 1 
    2424 
    2525#ifdef  __cplusplus 
     
    2727#endif 
    2828 
    29 /* For communication from `getopt' to the caller. 
    30    When `getopt' finds an option that takes an argument, 
     29/* For communication from `pj_getopt' to the caller. 
     30   When `pj_getopt' finds an option that takes an argument, 
    3131   the argument value is returned here. 
    3232   Also, when `ordering' is RETURN_IN_ORDER, 
    3333   each non-option ARGV-element is returned here.  */ 
    3434 
    35 extern char *optarg; 
     35extern char *pj_optarg; 
    3636 
    3737/* Index in ARGV of the next element to be scanned. 
    3838   This is used for communication to and from the caller 
    39    and for communication between successive calls to `getopt'. 
     39   and for communication between successive calls to `pj_getopt'. 
    4040 
    41    On entry to `getopt', zero means this is the first call; initialize. 
     41   On entry to `pj_getopt', zero means this is the first call; initialize. 
    4242 
    43    When `getopt' returns -1, this is the index of the first of the 
     43   When `pj_getopt' returns -1, this is the index of the first of the 
    4444   non-option elements that the caller should itself scan. 
    4545 
    46    Otherwise, `optind' communicates from one call to the next 
     46   Otherwise, `pj_optind' communicates from one call to the next 
    4747   how much of ARGV has been scanned so far.  */ 
    4848 
    49 extern int optind; 
     49extern int pj_optind; 
    5050 
    51 /* Callers store zero here to inhibit the error message `getopt' prints 
     51/* Callers store zero here to inhibit the error message `pj_getopt' prints 
    5252   for unrecognized options.  */ 
    5353 
    54 extern int opterr; 
     54extern int pj_opterr; 
    5555 
    5656/* Set to an option character which was unrecognized.  */ 
    5757 
    58 extern int optopt; 
     58extern int pj_optopt; 
    5959 
    6060/* Describe the long-named options requested by the application. 
    61    The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 
    62    of `struct option' terminated by an element containing a name which is 
     61   The LONG_OPTIONS argument to pj_getopt_long or pj_getopt_long_only is a vector 
     62   of `struct pj_getopt_option' terminated by an element containing a name which is 
    6363   zero. 
    6464 
     
    7373 
    7474   To have a long-named option do something other than set an `int' to 
    75    a compiled-in constant, such as set a value from `optarg', set the 
     75   a compiled-in constant, such as set a value from `pj_optarg', set the 
    7676   option's `flag' field to zero and its `val' field to a nonzero 
    7777   value (the equivalent single-letter option character, if there is 
    78    one).  For long options that have a zero `flag' field, `getopt' 
     78   one).  For long options that have a zero `flag' field, `pj_getopt' 
    7979   returns the contents of the `val' field.  */ 
    8080 
    81 struct option 
     81struct pj_getopt_option 
    8282{ 
    8383  const char *name; 
     
    8989}; 
    9090 
    91 /* Names for the values of the `has_arg' field of `struct option'.  */ 
     91/* Names for the values of the `has_arg' field of `struct pj_getopt_option'.  */ 
    9292 
    9393# define no_argument            0 
     
    102102   Return the option character from OPTS just read.  Return -1 when 
    103103   there are no more options.  For unrecognized options, or options 
    104    missing arguments, `optopt' is set to the option letter, and '?' is 
     104   missing arguments, `pj_optopt' is set to the option letter, and '?' is 
    105105   returned. 
    106106 
    107107   The OPTS string is a list of characters which are recognized option 
    108108   letters, optionally followed by colons, specifying that that letter 
    109    takes an argument, to be placed in `optarg'. 
     109   takes an argument, to be placed in `pj_optarg'. 
    110110 
    111111   If a letter in OPTS is followed by two colons, its argument is 
    112    optional.  This behavior is specific to the GNU `getopt'. 
     112   optional.  This behavior is specific to the GNU `pj_getopt'. 
    113113 
    114114   The argument `--' causes premature termination of argument 
    115    scanning, explicitly telling `getopt' that there are no more 
     115   scanning, explicitly telling `pj_getopt' that there are no more 
    116116   options. 
    117117 
    118118   If OPTS begins with `--', then non-option arguments are treated as 
    119119   arguments to the option '\0'.  This behavior is specific to the GNU 
    120    `getopt'.  */ 
     120   `pj_getopt'.  */ 
    121121 
    122 int getopt (int argc, char *const *argv, const char *shortopts); 
     122int pj_getopt (int argc, char *const *argv, const char *shortopts); 
    123123 
    124 int getopt_long (int argc, char *const *argv, const char *options, 
    125                         const struct option *longopts, int *longind); 
    126 int getopt_long_only (int argc, char *const *argv, 
     124int pj_getopt_long (int argc, char *const *argv, const char *options, 
     125                        const struct pj_getopt_option *longopts, int *longind); 
     126int pj_getopt_long_only (int argc, char *const *argv, 
    127127                             const char *shortopts, 
    128                              const struct option *longopts, int *longind); 
     128                             const struct pj_getopt_option *longopts, int *longind); 
    129129 
    130130 
     
    133133#endif 
    134134 
    135 #endif /* getopt.h */ 
     135#endif /* pj_getopt.h */ 
    136136 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r293 r300  
    466466 */ 
    467467pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata, 
    468                                 const pjsip_accept_hdr **p_accept_hdr); 
     468                                pjsip_accept_hdr **p_accept_hdr); 
    469469 
    470470/** 
  • pjproject/trunk/pjsip/src/pjsua-lib/getopt.c

    r238 r300  
    1919 
    2020/*  
    21  * getopt entry points 
     21 * pj_getopt entry points 
    2222 * 
    2323 * modified by Mike Borella <mike_borella@mw.3com.com> 
     
    3333int _getopt_internal (int argc, char *const *argv, 
    3434                      const char *shortopts, 
    35                       const struct option *longopts, int *longind, 
     35                      const struct pj_getopt_option *longopts, int *longind, 
    3636                      int long_only); 
    3737 
    38 /* getopt_long and getopt_long_only entry points for GNU getopt. 
     38/* pj_getopt_long and pj_getopt_long_only entry points for GNU pj_getopt. 
    3939   Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. 
    4040   This file is part of the GNU C Library. 
     
    6868 
    6969int 
    70 getopt_long (int argc, char *const *argv, const char *options,  
    71              const struct option *long_options, int *opt_index) 
     70pj_getopt_long (int argc, char *const *argv, const char *options,  
     71             const struct pj_getopt_option *long_options, int *opt_index) 
    7272{ 
    7373  return _getopt_internal (argc, argv, options, long_options, opt_index, 0); 
    7474} 
    7575 
    76 /* Like getopt_long, but '-' as well as '--' can indicate a long option. 
     76/* Like pj_getopt_long, but '-' as well as '--' can indicate a long option. 
    7777   If an option that starts with '-' (not '--') doesn't match a long option, 
    7878   but does match a short option, it is parsed as a short option 
     
    8080  
    8181int 
    82 getopt (int argc, char * const * argv, const char * optstring) 
     82pj_getopt (int argc, char * const * argv, const char * optstring) 
    8383{ 
    8484  return _getopt_internal (argc, argv, optstring, 
    85                            (const struct option *) 0, 
     85                           (const struct pj_getopt_option *) 0, 
    8686                           (int *) 0, 
    8787                           0); 
     
    9191#define _(msgid)        (msgid) 
    9292 
    93 /* This version of `getopt' appears to the caller like standard Unix `getopt' 
     93/* This version of `pj_getopt' appears to the caller like standard Unix `pj_getopt' 
    9494   but it behaves differently for the user, since it allows the user 
    9595   to intersperse the options with the other arguments. 
    9696 
    97    As `getopt' works, it permutes the elements of ARGV so that, 
     97   As `pj_getopt' works, it permutes the elements of ARGV so that, 
    9898   when it is done, all the options precede everything else.  Thus 
    9999   all application programs are extended to handle flexible argument order. 
     
    105105   they can distinguish the relative order of options and other arguments.  */ 
    106106 
    107 /* For communication from `getopt' to the caller. 
    108    When `getopt' finds an option that takes an argument, 
     107/* For communication from `pj_getopt' to the caller. 
     108   When `pj_getopt' finds an option that takes an argument, 
    109109   the argument value is returned here. 
    110110   Also, when `ordering' is RETURN_IN_ORDER, 
    111111   each non-option ARGV-element is returned here.  */ 
    112112 
    113 char *optarg = NULL; 
     113char *pj_optarg = NULL; 
    114114 
    115115/* Index in ARGV of the next element to be scanned. 
    116116   This is used for communication to and from the caller 
    117    and for communication between successive calls to `getopt'. 
    118  
    119    On entry to `getopt', zero means this is the first call; initialize. 
    120  
    121    When `getopt' returns -1, this is the index of the first of the 
     117   and for communication between successive calls to `pj_getopt'. 
     118 
     119   On entry to `pj_getopt', zero means this is the first call; initialize. 
     120 
     121   When `pj_getopt' returns -1, this is the index of the first of the 
    122122   non-option elements that the caller should itself scan. 
    123123 
    124    Otherwise, `optind' communicates from one call to the next 
     124   Otherwise, `pj_optind' communicates from one call to the next 
    125125   how much of ARGV has been scanned so far.  */ 
    126126 
    127127/* 1003.2 says this must be 1 before any call.  */ 
    128 int optind = 1; 
    129  
    130 /* Formerly, initialization of getopt depended on optind==0, which 
    131    causes problems with re-calling getopt as programs generally don't 
     128int pj_optind = 1; 
     129 
     130/* Formerly, initialization of pj_getopt depended on pj_optind==0, which 
     131   causes problems with re-calling pj_getopt as programs generally don't 
    132132   know that. */ 
    133133 
     
    145145/* Set to an option character which was unrecognized. 
    146146   This must be initialized on some systems to avoid linking in the 
    147    system's own getopt implementation.  */ 
    148  
    149 int optopt = '?'; 
     147   system's own pj_getopt implementation.  */ 
     148 
     149int pj_optopt = '?'; 
    150150 
    151151/* Describe how to deal with options that follow non-option ARGV-elements. 
     
    176176   The special argument `--' forces an end of option-scanning regardless 
    177177   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only 
    178    `--' can cause `getopt' to return -1 with `optind' != ARGC.  */ 
     178   `--' can cause `pj_getopt' to return -1 with `pj_optind' != ARGC.  */ 
    179179 
    180180static enum 
     
    213213   One subsequence is elements [first_nonopt,last_nonopt) 
    214214   which contains all the non-options that have been skipped so far. 
    215    The other is elements [last_nonopt,optind), which contains all 
     215   The other is elements [last_nonopt,pj_optind), which contains all 
    216216   the options processed since those non-options were skipped. 
    217217 
     
    224224  int bottom = first_nonopt; 
    225225  int middle = last_nonopt; 
    226   int top = optind; 
     226  int top = pj_optind; 
    227227  char *tem; 
    228228 
     
    272272  /* Update records for the slots the non-options now occupy.  */ 
    273273 
    274   first_nonopt += (optind - last_nonopt); 
    275   last_nonopt = optind; 
     274  first_nonopt += (pj_optind - last_nonopt); 
     275  last_nonopt = pj_optind; 
    276276} 
    277277 
     
    288288     non-option ARGV-elements is empty.  */ 
    289289 
    290   first_nonopt = last_nonopt = optind; 
     290  first_nonopt = last_nonopt = pj_optind; 
    291291 
    292292  nextchar = NULL; 
     
    320320   If an element of ARGV starts with '-', and is not exactly "-" or "--", 
    321321   then it is an option element.  The characters of this element 
    322    (aside from the initial '-') are option characters.  If `getopt' 
     322   (aside from the initial '-') are option characters.  If `pj_getopt' 
    323323   is called repeatedly, it returns successively each of the option characters 
    324324   from each of the option elements. 
    325325 
    326    If `getopt' finds another option character, it returns that character, 
    327    updating `optind' and `nextchar' so that the next call to `getopt' can 
     326   If `pj_getopt' finds another option character, it returns that character, 
     327   updating `pj_optind' and `nextchar' so that the next call to `pj_getopt' can 
    328328   resume the scan with the following option character or ARGV-element. 
    329329 
    330    If there are no more option characters, `getopt' returns -1. 
    331    Then `optind' is the index in ARGV of the first ARGV-element 
     330   If there are no more option characters, `pj_getopt' returns -1. 
     331   Then `pj_optind' is the index in ARGV of the first ARGV-element 
    332332   that is not an option.  (The ARGV-elements have been permuted 
    333333   so that those that are not options now come last.) 
     
    335335   OPTSTRING is a string containing the legitimate option characters. 
    336336   If an option character is seen that is not listed in OPTSTRING, 
    337    return '?' after printing an error message.  If you set `opterr' to 
     337   return '?' after printing an error message.  If you set `pj_opterr' to 
    338338   zero, the error message is suppressed but we still return '?'. 
    339339 
    340340   If a char in OPTSTRING is followed by a colon, that means it wants an arg, 
    341341   so the following text in the same ARGV-element, or the text of the following 
    342    ARGV-element, is returned in `optarg'.  Two colons mean an option that 
     342   ARGV-element, is returned in `pj_optarg'.  Two colons mean an option that 
    343343   wants an optional arg; if there is text in the current ARGV-element, 
    344    it is returned in `optarg', otherwise `optarg' is set to zero. 
     344   it is returned in `pj_optarg', otherwise `pj_optarg' is set to zero. 
    345345 
    346346   If OPTSTRING starts with `-' or `+', it requests different methods of 
     
    353353   argument, it follows the option name in the same ARGV-element, separated 
    354354   from the option name by a `=', or else the in next ARGV-element. 
    355    When `getopt' finds a long-named option, it returns 0 if that option's 
     355   When `pj_getopt' finds a long-named option, it returns 0 if that option's 
    356356   `flag' field is nonzero, the value of the option's `val' field 
    357357   if the `flag' field is zero. 
     
    361361   with other systems. 
    362362 
    363    LONGOPTS is a vector of `struct option' terminated by an 
     363   LONGOPTS is a vector of `struct pj_getopt_option' terminated by an 
    364364   element containing a name which is zero. 
    365365 
     
    373373static int 
    374374_getopt_internal (int argc, char *const *argv, const char *optstring,  
    375                   const struct option *longopts, int *longind,  
     375                  const struct pj_getopt_option *longopts, int *longind,  
    376376                  int long_only) 
    377377{ 
    378   optarg = NULL; 
    379  
    380   if (optind == 0 || !__getopt_initialized) 
     378  pj_optarg = NULL; 
     379 
     380  if (pj_optind == 0 || !__getopt_initialized) 
    381381    { 
    382       if (optind == 0) 
    383         optind = 1;     /* Don't scan ARGV[0], the program name.  */ 
     382      if (pj_optind == 0) 
     383        pj_optind = 1;  /* Don't scan ARGV[0], the program name.  */ 
    384384      optstring = _getopt_initialize (argc, argv, optstring); 
    385385      __getopt_initialized = 1; 
    386386    } 
    387387 
    388   /* Test whether ARGV[optind] points to a non-option argument. 
     388  /* Test whether ARGV[pj_optind] points to a non-option argument. 
    389389     Either it does not have option syntax, or there is an environment flag 
    390390     from the shell indicating it is not an option.  The later information 
    391391     is only used when the used in the GNU libc.  */ 
    392 #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') 
     392#define NONOPTION_P (argv[pj_optind][0] != '-' || argv[pj_optind][1] == '\0') 
    393393 
    394394  if (nextchar == NULL || *nextchar == '\0') 
     
    398398      /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been 
    399399         moved back by the user (who may also have changed the arguments).  */ 
    400       if (last_nonopt > optind) 
    401         last_nonopt = optind; 
    402       if (first_nonopt > optind) 
    403         first_nonopt = optind; 
     400      if (last_nonopt > pj_optind) 
     401        last_nonopt = pj_optind; 
     402      if (first_nonopt > pj_optind) 
     403        first_nonopt = pj_optind; 
    404404 
    405405      if (ordering == PERMUTE) 
     
    408408             exchange them so that the options come first.  */ 
    409409 
    410           if (first_nonopt != last_nonopt && last_nonopt != optind) 
     410          if (first_nonopt != last_nonopt && last_nonopt != pj_optind) 
    411411            exchange ((char **) argv); 
    412           else if (last_nonopt != optind) 
    413             first_nonopt = optind; 
     412          else if (last_nonopt != pj_optind) 
     413            first_nonopt = pj_optind; 
    414414 
    415415          /* Skip any additional non-options 
    416416             and extend the range of non-options previously skipped.  */ 
    417417 
    418           while (optind < argc && NONOPTION_P) 
    419             optind++; 
    420           last_nonopt = optind; 
     418          while (pj_optind < argc && NONOPTION_P) 
     419            pj_optind++; 
     420          last_nonopt = pj_optind; 
    421421        } 
    422422 
     
    426426         then skip everything else like a non-option.  */ 
    427427 
    428       if (optind != argc && !pj_ansi_strcmp(argv[optind], "--")) 
    429         { 
    430           optind++; 
    431  
    432           if (first_nonopt != last_nonopt && last_nonopt != optind) 
     428      if (pj_optind != argc && !pj_ansi_strcmp(argv[pj_optind], "--")) 
     429        { 
     430          pj_optind++; 
     431 
     432          if (first_nonopt != last_nonopt && last_nonopt != pj_optind) 
    433433            exchange ((char **) argv); 
    434434          else if (first_nonopt == last_nonopt) 
    435             first_nonopt = optind; 
     435            first_nonopt = pj_optind; 
    436436          last_nonopt = argc; 
    437437 
    438           optind = argc; 
     438          pj_optind = argc; 
    439439        } 
    440440 
     
    442442         and back over any non-options that we skipped and permuted.  */ 
    443443 
    444       if (optind == argc) 
     444      if (pj_optind == argc) 
    445445        { 
    446446          /* Set the next-arg-index to point at the non-options 
    447447             that we previously skipped, so the caller will digest them.  */ 
    448448          if (first_nonopt != last_nonopt) 
    449             optind = first_nonopt; 
     449            pj_optind = first_nonopt; 
    450450          return -1; 
    451451        } 
     
    458458          if (ordering == REQUIRE_ORDER) 
    459459            return -1; 
    460           optarg = argv[optind++]; 
     460          pj_optarg = argv[pj_optind++]; 
    461461          return 1; 
    462462        } 
     
    465465         Skip the initial punctuation.  */ 
    466466 
    467       nextchar = (argv[optind] + 1 
    468                   + (longopts != NULL && argv[optind][1] == '-')); 
     467      nextchar = (argv[pj_optind] + 1 
     468                  + (longopts != NULL && argv[pj_optind][1] == '-')); 
    469469    } 
    470470 
     
    485485 
    486486  if (longopts != NULL 
    487       && (argv[optind][1] == '-' 
    488           || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) 
     487      && (argv[pj_optind][1] == '-' 
     488          || (long_only && (argv[pj_optind][2] || !my_index (optstring, argv[pj_optind][1]))))) 
    489489    { 
    490490      char *nameend; 
    491       const struct option *p; 
    492       const struct option *pfound = NULL; 
     491      const struct pj_getopt_option *p; 
     492      const struct pj_getopt_option *pfound = NULL; 
    493493      int exact = 0; 
    494494      int ambig = 0; 
     
    527527        { 
    528528          nextchar += strlen (nextchar); 
    529           optind++; 
    530           optopt = 0; 
     529          pj_optind++; 
     530          pj_optopt = 0; 
    531531          return '?'; 
    532532        } 
     
    535535        { 
    536536          option_index = indfound; 
    537           optind++; 
     537          pj_optind++; 
    538538          if (*nameend) 
    539539            { 
     
    541541                 allow it to be used on enums.  */ 
    542542              if (pfound->has_arg) 
    543                 optarg = nameend + 1; 
     543                pj_optarg = nameend + 1; 
    544544              else 
    545545                { 
    546546                  nextchar += strlen (nextchar); 
    547547 
    548                   optopt = pfound->val; 
     548                  pj_optopt = pfound->val; 
    549549                  return '?'; 
    550550                } 
     
    552552          else if (pfound->has_arg == 1) 
    553553            { 
    554               if (optind < argc) 
    555                 optarg = argv[optind++]; 
     554              if (pj_optind < argc) 
     555                pj_optarg = argv[pj_optind++]; 
    556556              else 
    557557                { 
    558558                  nextchar += strlen (nextchar); 
    559                   optopt = pfound->val; 
     559                  pj_optopt = pfound->val; 
    560560                  return optstring[0] == ':' ? ':' : '?'; 
    561561                } 
     
    572572        } 
    573573 
    574       /* Can't find it as a long option.  If this is not getopt_long_only, 
     574      /* Can't find it as a long option.  If this is not pj_getopt_long_only, 
    575575         or the option starts with '--' or is not a valid short 
    576576         option, then it's an error. 
    577577         Otherwise interpret it as a short option.  */ 
    578       if (!long_only || argv[optind][1] == '-' 
     578      if (!long_only || argv[pj_optind][1] == '-' 
    579579          || my_index (optstring, *nextchar) == NULL) 
    580580        { 
    581581          nextchar = (char *) ""; 
    582           optind++; 
    583           optopt = 0; 
     582          pj_optind++; 
     583          pj_optopt = 0; 
    584584          return '?'; 
    585585        } 
     
    592592    char *temp = my_index (optstring, c); 
    593593 
    594     /* Increment `optind' when we start to process its last character.  */ 
     594    /* Increment `pj_optind' when we start to process its last character.  */ 
    595595    if (*nextchar == '\0') 
    596       ++optind; 
     596      ++pj_optind; 
    597597 
    598598    if (temp == NULL || c == ':') 
    599599      { 
    600         optopt = c; 
     600        pj_optopt = c; 
    601601        return '?'; 
    602602      } 
     
    605605      { 
    606606        char *nameend; 
    607         const struct option *p; 
    608         const struct option *pfound = NULL; 
     607        const struct pj_getopt_option *p; 
     608        const struct pj_getopt_option *pfound = NULL; 
    609609        int exact = 0; 
    610610        int ambig = 0; 
     
    615615        if (*nextchar != '\0') 
    616616          { 
    617             optarg = nextchar; 
     617            pj_optarg = nextchar; 
    618618            /* If we end this ARGV-element by taking the rest as an arg, 
    619619               we must advance to the next element now.  */ 
    620             optind++; 
     620            pj_optind++; 
    621621          } 
    622         else if (optind == argc) 
     622        else if (pj_optind == argc) 
    623623          { 
    624             optopt = c; 
     624            pj_optopt = c; 
    625625            if (optstring[0] == ':') 
    626626              c = ':'; 
     
    630630          } 
    631631        else 
    632           /* We already incremented `optind' once; 
     632          /* We already incremented `pj_optind' once; 
    633633             increment it again when taking next ARGV-elt as argument.  */ 
    634           optarg = argv[optind++]; 
    635  
    636         /* optarg is now the argument, see if it's in the 
     634          pj_optarg = argv[pj_optind++]; 
     635 
     636        /* pj_optarg is now the argument, see if it's in the 
    637637           table of longopts.  */ 
    638638 
    639         for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) 
     639        for (nextchar = nameend = pj_optarg; *nameend && *nameend != '='; nameend++) 
    640640          /* Do nothing.  */ ; 
    641641 
     
    666666          { 
    667667            nextchar += strlen (nextchar); 
    668             optind++; 
     668            pj_optind++; 
    669669            return '?'; 
    670670          } 
     
    677677                   allow it to be used on enums.  */ 
    678678                if (pfound->has_arg) 
    679                   optarg = nameend + 1; 
     679                  pj_optarg = nameend + 1; 
    680680                else 
    681681                  { 
     
    686686            else if (pfound->has_arg == 1) 
    687687              { 
    688                 if (optind < argc) 
    689                   optarg = argv[optind++]; 
     688                if (pj_optind < argc) 
     689                  pj_optarg = argv[pj_optind++]; 
    690690                else 
    691691                  { 
     
    714714            if (*nextchar != '\0') 
    715715              { 
    716                 optarg = nextchar; 
    717                 optind++; 
     716                pj_optarg = nextchar; 
     717                pj_optind++; 
    718718              } 
    719719            else 
    720               optarg = NULL; 
     720              pj_optarg = NULL; 
    721721            nextchar = NULL; 
    722722          } 
     
    726726            if (*nextchar != '\0') 
    727727              { 
    728                 optarg = nextchar; 
     728                pj_optarg = nextchar; 
    729729                /* If we end this ARGV-element by taking the rest as an arg, 
    730730                   we must advance to the next element now.  */ 
    731                 optind++; 
     731                pj_optind++; 
    732732              } 
    733             else if (optind == argc) 
     733            else if (pj_optind == argc) 
    734734              { 
    735                 optopt = c; 
     735                pj_optopt = c; 
    736736                if (optstring[0] == ':') 
    737737                  c = ':'; 
     
    740740              } 
    741741            else 
    742               /* We already incremented `optind' once; 
     742              /* We already incremented `pj_optind' once; 
    743743                 increment it again when taking next ARGV-elt as argument.  */ 
    744               optarg = argv[optind++]; 
     744              pj_optarg = argv[pj_optind++]; 
    745745            nextchar = NULL; 
    746746          } 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c

    r268 r300  
    108108 */ 
    109109pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata, 
    110                                 const pjsip_accept_hdr **p_accept_hdr) 
     110                                pjsip_accept_hdr **p_accept_hdr) 
    111111{ 
    112112    pjsip_ctype_hdr *ctype; 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c

    r293 r300  
    228228           OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 
    229229    }; 
    230     struct option long_options[] = { 
     230    struct pj_getopt_option long_options[] = { 
    231231        { "config-file",1, 0, OPT_CONFIG_FILE}, 
    232232        { "log-file",   1, 0, OPT_LOG_FILE}, 
     
    273273    char *config_file = NULL; 
    274274 
    275     /* Run getopt once to see if user specifies config file to read. */ 
    276     while ((c=getopt_long(argc, argv, "", long_options, &option_index)) != -1) { 
     275    /* Run pj_getopt once to see if user specifies config file to read. */  
     276    while ((c=pj_getopt_long(argc, argv, "", long_options, &option_index)) != -1) { 
    277277        switch (c) { 
    278278        case OPT_CONFIG_FILE: 
    279             config_file = optarg; 
     279            config_file = pj_optarg; 
    280280            break; 
    281281        } 
     
    295295 
    296296 
    297     /* Reinitialize and re-run getopt again, possibly with new arguments 
     297    /* Reinitialize and re-run pj_getopt again, possibly with new arguments 
    298298     * read from config file. 
    299299     */ 
    300     optind = 0; 
    301     while ((c=getopt_long(argc, argv, "", long_options, &option_index)) != -1) { 
     300    pj_optind = 0; 
     301    while((c=pj_getopt_long(argc, argv, "", long_options, &option_index))!=-1) { 
    302302        char *p; 
    303303        pj_str_t tmp; 
     
    307307 
    308308        case OPT_LOG_FILE: 
    309             pjsua.log_filename = optarg; 
     309            pjsua.log_filename = pj_optarg; 
    310310            break; 
    311311 
    312312        case OPT_LOG_LEVEL: 
    313             c = pj_strtoul(pj_cstr(&tmp, optarg)); 
     313            c = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    314314            if (c < 0 || c > 6) { 
    315315                printf("Error: expecting integer value 0-6 for --log-level\n"); 
     
    320320 
    321321        case OPT_APP_LOG_LEVEL: 
    322             pjsua.app_log_level = pj_strtoul(pj_cstr(&tmp, optarg)); 
     322            pjsua.app_log_level = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    323323            if (pjsua.app_log_level < 0 || pjsua.app_log_level > 6) { 
    324324                printf("Error: expecting integer value 0-6 for --app-log-level\n"); 
     
    348348 
    349349        case OPT_LOCAL_PORT:   /* local-port */ 
    350             lval = pj_strtoul(pj_cstr(&tmp, optarg)); 
     350            lval = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
    351351            if (lval < 1 || lval > 65535) { 
    352352                printf("Error: expecting integer value for --local-port\n"); 
     
    357357 
    358358        case OPT_PROXY:   /* proxy */ 
    359             if (pjsua_verify_sip_url(optarg) != 0) { 
    360                 printf("Error: invalid SIP URL '%s' in proxy argument\n", optarg); 
     359            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
     360                printf("Error: invalid SIP URL '%s' in proxy argument\n", pj_optarg); 
    361361                return PJ_EINVAL; 
    362362            } 
    363             cur_acc->proxy = pj_str(optarg); 
     363            cur_acc->proxy = pj_str(pj_optarg); 
    364364            break; 
    365365 
    366366        case OPT_OUTBOUND_PROXY:   /* outbound proxy */ 
    367             if (pjsua_verify_sip_url(optarg) != 0) { 
    368                 printf("Error: invalid SIP URL '%s' in outbound proxy argument\n", optarg); 
     367            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
     368                printf("Error: invalid SIP URL '%s' in outbound proxy argument\n", pj_optarg); 
    369369                return PJ_EINVAL; 
    370370            } 
    371             pjsua.outbound_proxy = pj_str(optarg); 
     371            pjsua.outbound_proxy = pj_str(pj_optarg); 
    372372            break; 
    373373 
    374374        case OPT_REGISTRAR:   /* registrar */ 
    375             if (pjsua_verify_sip_url(optarg) != 0) { 
    376                 printf("Error: invalid SIP URL '%s' in registrar argument\n", optarg); 
     375            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
     376                printf("Error: invalid SIP URL '%s' in registrar argument\n", pj_optarg); 
    377377                return PJ_EINVAL; 
    378378            } 
    379             cur_acc->reg_uri = pj_str(optarg); 
     379            cur_acc->reg_uri = pj_str(pj_optarg); 
    380380            break; 
    381381 
    382382        case OPT_REG_TIMEOUT:   /* reg-timeout */ 
    383             cur_acc->reg_timeout = pj_strtoul(pj_cstr(&tmp,optarg)); 
     383            cur_acc->reg_timeout = pj_strtoul(pj_cstr(&tmp,pj_optarg)); 
    384384            if (cur_acc->reg_timeout < 1 || cur_acc->reg_timeout > 3600) { 
    385385                printf("Error: invalid value for --reg-timeout (expecting 1-3600)\n"); 
     
    389389 
    390390        case OPT_ID:   /* id */ 
    391             if (pjsua_verify_sip_url(optarg) != 0) { 
    392                 printf("Error: invalid SIP URL '%s' in local id argument\n", optarg); 
     391            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
     392                printf("Error: invalid SIP URL '%s' in local id argument\n", pj_optarg); 
    393393                return PJ_EINVAL; 
    394394            } 
    395             cur_acc->local_uri = pj_str(optarg); 
     395            cur_acc->local_uri = pj_str(pj_optarg); 
    396396            pjsua.has_acc = 1; 
    397397            break; 
    398398 
    399399        case OPT_CONTACT:   /* contact */ 
    400             if (pjsua_verify_sip_url(optarg) != 0) { 
    401                 printf("Error: invalid SIP URL '%s' in contact argument\n", optarg); 
     400            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
     401                printf("Error: invalid SIP URL '%s' in contact argument\n", pj_optarg); 
    402402                return PJ_EINVAL; 
    403403            } 
    404             cur_acc->contact_uri = pj_str(optarg); 
     404            cur_acc->contact_uri = pj_str(pj_optarg); 
    405405            break; 
    406406 
     
    412412        case OPT_USERNAME:   /* Default authentication user */ 
    413413            if (pjsua.cred_count==0) pjsua.cred_count=1; 
    414             cur_cred->username = pj_str(optarg); 
     414            cur_cred->username = pj_str(pj_optarg); 
    415415            break; 
    416416 
    417417        case OPT_REALM:     /* Default authentication realm. */ 
    418418            if (pjsua.cred_count==0) pjsua.cred_count=1; 
    419             cur_cred->realm = pj_str(optarg); 
     419            cur_cred->realm = pj_str(pj_optarg); 
    420420            break; 
    421421 
     
    423423            if (pjsua.cred_count==0) pjsua.cred_count=1; 
    424424            cur_cred->data_type = 0; 
    425             cur_cred->data = pj_str(optarg); 
     425            cur_cred->data = pj_str(pj_optarg); 
    426426            break; 
    427427 
     
    432432 
    433433        case OPT_USE_STUN1:   /* STUN server 1 */ 
    434             p = pj_ansi_strchr(optarg, ':'); 
     434            p = pj_ansi_strchr(pj_optarg, ':'); 
    435435            if (p) { 
    436436                *p = '\0'; 
    437                 pjsua.stun_srv1 = pj_str(optarg); 
     437                pjsua.stun_srv1 = pj_str(pj_optarg); 
    438438                pjsua.stun_port1 = pj_strtoul(pj_cstr(&tmp, p+1)); 
    439439                if (pjsua.stun_port1 < 1 || pjsua.stun_port1 > 65535) { 
     
    443443            } else { 
    444444                pjsua.stun_port1 = 3478; 
    445                 pjsua.stun_srv1 = pj_str(optarg); 
     445                pjsua.stun_srv1 = pj_str(pj_optarg); 
    446446            } 
    447447            break; 
    448448 
    449449        case OPT_USE_STUN2:   /* STUN server 2 */ 
    450             p = pj_ansi_strchr(optarg, ':'); 
     450            p = pj_ansi_strchr(pj_optarg, ':'); 
    451451            if (p) { 
    452452                *p = '\0'; 
    453                 pjsua.stun_srv2 = pj_str(optarg); 
     453                pjsua.stun_srv2 = pj_str(pj_optarg); 
    454454                pjsua.stun_port2 = pj_strtoul(pj_cstr(&tmp,p+1)); 
    455455                if (pjsua.stun_port2 < 1 || pjsua.stun_port2 > 65535) { 
     
    459459            } else { 
    460460                pjsua.stun_port2 = 3478; 
    461                 pjsua.stun_srv2 = pj_str(optarg); 
     461                pjsua.stun_srv2 = pj_str(pj_optarg); 
    462462            } 
    463463            break; 
    464464 
    465465        case OPT_ADD_BUDDY: /* Add to buddy list. */ 
    466             if (pjsua_verify_sip_url(optarg) != 0) { 
    467                 printf("Error: invalid URL '%s' in --add-buddy option\n", optarg); 
     466            if (pjsua_verify_sip_url(pj_optarg) != 0) { 
     467                printf("Error: invalid URL '%s' in --add-buddy option\n", pj_optarg); 
    468468                return -1; 
    469469            } 
     
    472472                return -1; 
    473473            } 
    474             pjsua.buddies[pjsua.buddy_cnt++].uri = pj_str(optarg); 
     474            pjsua.buddies[pjsua.buddy_cnt++].uri = pj_str(pj_optarg); 
    475475            break; 
    476476 
     
    488488 
    489489        case OPT_PLAY_FILE: 
    490             pjsua.wav_file = optarg; 
     490            pjsua.wav_file = pj_optarg; 
    491491            break; 
    492492 
    493493        case OPT_RTP_PORT: 
    494             pjsua.start_rtp_port = my_atoi(optarg); 
     494            pjsua.start_rtp_port = my_atoi(pj_optarg); 
    495495            if (pjsua.start_rtp_port < 1 || pjsua.start_rtp_port > 65535) { 
    496496                PJ_LOG(1,(THIS_FILE, 
     
    500500 
    501501        case OPT_ADD_CODEC: 
    502             pjsua.codec_arg[pjsua.codec_cnt++] = pj_str(optarg); 
     502            pjsua.codec_arg[pjsua.codec_cnt++] = pj_str(pj_optarg); 
    503503            break; 
    504504 
    505505        case OPT_COMPLEXITY: 
    506             pjsua.complexity = my_atoi(optarg); 
     506            pjsua.complexity = my_atoi(pj_optarg); 
    507507            if (pjsua.complexity < 0 || pjsua.complexity > 10) { 
    508508                PJ_LOG(1,(THIS_FILE, 
     
    513513 
    514514        case OPT_QUALITY: 
    515             pjsua.quality = my_atoi(optarg); 
     515            pjsua.quality = my_atoi(pj_optarg); 
    516516            if (pjsua.quality < 0 || pjsua.quality > 10) { 
    517517                PJ_LOG(1,(THIS_FILE, 
     
    522522 
    523523        case OPT_AUTO_ANSWER: 
    524             pjsua.auto_answer = my_atoi(optarg); 
     524            pjsua.auto_answer = my_atoi(pj_optarg); 
    525525            if (pjsua.auto_answer < 100 || pjsua.auto_answer > 699) { 
    526526                PJ_LOG(1,(THIS_FILE, 
     
    531531 
    532532        case OPT_MAX_CALLS: 
    533             pjsua.max_calls = my_atoi(optarg); 
     533            pjsua.max_calls = my_atoi(pj_optarg); 
    534534            if (pjsua.max_calls < 1 || pjsua.max_calls > 255) { 
    535535                PJ_LOG(1,(THIS_FILE,"Too many calls for max-calls (1-255)")); 
     
    540540    } 
    541541 
    542     if (optind != argc) { 
    543         printf("Error: unknown options %s\n", argv[optind]); 
     542    if (pj_optind != argc) { 
     543        printf("Error: unknown options %s\n", argv[pj_optind]); 
    544544        return PJ_EINVAL; 
    545545    } 
Note: See TracChangeset for help on using the changeset viewer.