- Timestamp:
- Mar 6, 2006 3:14:59 PM (19 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/build/Makefile
r296 r300 71 71 export PJSUA_LIB_SRCDIR = ../src/pjsua-lib 72 72 export 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 \ 75 75 76 76 export PJSUA_LIB_CFLAGS += $(_CFLAGS) -
pjproject/trunk/pjsip/include/pjsua-lib/getopt.h
r238 r300 1 1 /* $Id$ */ 2 2 /* This file has now become GPL. */ 3 /* Declarations for getopt.3 /* Declarations for pj_getopt. 4 4 Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. 5 5 This file is part of the GNU C Library. … … 20 20 Boston, MA 02111-1307, USA. */ 21 21 22 #ifndef _ GETOPT_H23 #define _ GETOPT_H122 #ifndef __PJ_GETOPT_H__ 23 #define __PJ_GETOPT_H__ 1 24 24 25 25 #ifdef __cplusplus … … 27 27 #endif 28 28 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, 31 31 the argument value is returned here. 32 32 Also, when `ordering' is RETURN_IN_ORDER, 33 33 each non-option ARGV-element is returned here. */ 34 34 35 extern char * optarg;35 extern char *pj_optarg; 36 36 37 37 /* Index in ARGV of the next element to be scanned. 38 38 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'. 40 40 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. 42 42 43 When ` getopt' returns -1, this is the index of the first of the43 When `pj_getopt' returns -1, this is the index of the first of the 44 44 non-option elements that the caller should itself scan. 45 45 46 Otherwise, ` optind' communicates from one call to the next46 Otherwise, `pj_optind' communicates from one call to the next 47 47 how much of ARGV has been scanned so far. */ 48 48 49 extern int optind;49 extern int pj_optind; 50 50 51 /* Callers store zero here to inhibit the error message ` getopt' prints51 /* Callers store zero here to inhibit the error message `pj_getopt' prints 52 52 for unrecognized options. */ 53 53 54 extern int opterr;54 extern int pj_opterr; 55 55 56 56 /* Set to an option character which was unrecognized. */ 57 57 58 extern int optopt;58 extern int pj_optopt; 59 59 60 60 /* Describe the long-named options requested by the application. 61 The LONG_OPTIONS argument to getopt_long orgetopt_long_only is a vector62 of `struct option' terminated by an element containing a name which is61 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 63 63 zero. 64 64 … … 73 73 74 74 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 the75 a compiled-in constant, such as set a value from `pj_optarg', set the 76 76 option's `flag' field to zero and its `val' field to a nonzero 77 77 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' 79 79 returns the contents of the `val' field. */ 80 80 81 struct option81 struct pj_getopt_option 82 82 { 83 83 const char *name; … … 89 89 }; 90 90 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'. */ 92 92 93 93 # define no_argument 0 … … 102 102 Return the option character from OPTS just read. Return -1 when 103 103 there are no more options. For unrecognized options, or options 104 missing arguments, ` optopt' is set to the option letter, and '?' is104 missing arguments, `pj_optopt' is set to the option letter, and '?' is 105 105 returned. 106 106 107 107 The OPTS string is a list of characters which are recognized option 108 108 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'. 110 110 111 111 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'. 113 113 114 114 The argument `--' causes premature termination of argument 115 scanning, explicitly telling ` getopt' that there are no more115 scanning, explicitly telling `pj_getopt' that there are no more 116 116 options. 117 117 118 118 If OPTS begins with `--', then non-option arguments are treated as 119 119 arguments to the option '\0'. This behavior is specific to the GNU 120 ` getopt'. */120 `pj_getopt'. */ 121 121 122 int getopt (int argc, char *const *argv, const char *shortopts);122 int pj_getopt (int argc, char *const *argv, const char *shortopts); 123 123 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,124 int pj_getopt_long (int argc, char *const *argv, const char *options, 125 const struct pj_getopt_option *longopts, int *longind); 126 int pj_getopt_long_only (int argc, char *const *argv, 127 127 const char *shortopts, 128 const struct option *longopts, int *longind);128 const struct pj_getopt_option *longopts, int *longind); 129 129 130 130 … … 133 133 #endif 134 134 135 #endif /* getopt.h */135 #endif /* pj_getopt.h */ 136 136 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r293 r300 466 466 */ 467 467 pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata, 468 constpjsip_accept_hdr **p_accept_hdr);468 pjsip_accept_hdr **p_accept_hdr); 469 469 470 470 /** -
pjproject/trunk/pjsip/src/pjsua-lib/getopt.c
r238 r300 19 19 20 20 /* 21 * getopt entry points21 * pj_getopt entry points 22 22 * 23 23 * modified by Mike Borella <mike_borella@mw.3com.com> … … 33 33 int _getopt_internal (int argc, char *const *argv, 34 34 const char *shortopts, 35 const struct option *longopts, int *longind,35 const struct pj_getopt_option *longopts, int *longind, 36 36 int long_only); 37 37 38 /* getopt_long and getopt_long_only entry points for GNUgetopt.38 /* pj_getopt_long and pj_getopt_long_only entry points for GNU pj_getopt. 39 39 Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. 40 40 This file is part of the GNU C Library. … … 68 68 69 69 int 70 getopt_long (int argc, char *const *argv, const char *options,71 const struct option *long_options, int *opt_index)70 pj_getopt_long (int argc, char *const *argv, const char *options, 71 const struct pj_getopt_option *long_options, int *opt_index) 72 72 { 73 73 return _getopt_internal (argc, argv, options, long_options, opt_index, 0); 74 74 } 75 75 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. 77 77 If an option that starts with '-' (not '--') doesn't match a long option, 78 78 but does match a short option, it is parsed as a short option … … 80 80 81 81 int 82 getopt (int argc, char * const * argv, const char * optstring)82 pj_getopt (int argc, char * const * argv, const char * optstring) 83 83 { 84 84 return _getopt_internal (argc, argv, optstring, 85 (const struct option *) 0,85 (const struct pj_getopt_option *) 0, 86 86 (int *) 0, 87 87 0); … … 91 91 #define _(msgid) (msgid) 92 92 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' 94 94 but it behaves differently for the user, since it allows the user 95 95 to intersperse the options with the other arguments. 96 96 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, 98 98 when it is done, all the options precede everything else. Thus 99 99 all application programs are extended to handle flexible argument order. … … 105 105 they can distinguish the relative order of options and other arguments. */ 106 106 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, 109 109 the argument value is returned here. 110 110 Also, when `ordering' is RETURN_IN_ORDER, 111 111 each non-option ARGV-element is returned here. */ 112 112 113 char * optarg = NULL;113 char *pj_optarg = NULL; 114 114 115 115 /* Index in ARGV of the next element to be scanned. 116 116 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 the117 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 122 122 non-option elements that the caller should itself scan. 123 123 124 Otherwise, ` optind' communicates from one call to the next124 Otherwise, `pj_optind' communicates from one call to the next 125 125 how much of ARGV has been scanned so far. */ 126 126 127 127 /* 1003.2 says this must be 1 before any call. */ 128 int optind = 1;129 130 /* Formerly, initialization of getopt depended onoptind==0, which131 causes problems with re-calling getopt as programs generally don't128 int 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 132 132 know that. */ 133 133 … … 145 145 /* Set to an option character which was unrecognized. 146 146 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 149 int pj_optopt = '?'; 150 150 151 151 /* Describe how to deal with options that follow non-option ARGV-elements. … … 176 176 The special argument `--' forces an end of option-scanning regardless 177 177 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. */ 179 179 180 180 static enum … … 213 213 One subsequence is elements [first_nonopt,last_nonopt) 214 214 which contains all the non-options that have been skipped so far. 215 The other is elements [last_nonopt, optind), which contains all215 The other is elements [last_nonopt,pj_optind), which contains all 216 216 the options processed since those non-options were skipped. 217 217 … … 224 224 int bottom = first_nonopt; 225 225 int middle = last_nonopt; 226 int top = optind;226 int top = pj_optind; 227 227 char *tem; 228 228 … … 272 272 /* Update records for the slots the non-options now occupy. */ 273 273 274 first_nonopt += ( optind - last_nonopt);275 last_nonopt = optind;274 first_nonopt += (pj_optind - last_nonopt); 275 last_nonopt = pj_optind; 276 276 } 277 277 … … 288 288 non-option ARGV-elements is empty. */ 289 289 290 first_nonopt = last_nonopt = optind;290 first_nonopt = last_nonopt = pj_optind; 291 291 292 292 nextchar = NULL; … … 320 320 If an element of ARGV starts with '-', and is not exactly "-" or "--", 321 321 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' 323 323 is called repeatedly, it returns successively each of the option characters 324 324 from each of the option elements. 325 325 326 If ` getopt' finds another option character, it returns that character,327 updating ` optind' and `nextchar' so that the next call to `getopt' can326 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 328 328 resume the scan with the following option character or ARGV-element. 329 329 330 If there are no more option characters, ` getopt' returns -1.331 Then ` optind' is the index in ARGV of the first ARGV-element330 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 332 332 that is not an option. (The ARGV-elements have been permuted 333 333 so that those that are not options now come last.) … … 335 335 OPTSTRING is a string containing the legitimate option characters. 336 336 If an option character is seen that is not listed in OPTSTRING, 337 return '?' after printing an error message. If you set ` opterr' to337 return '?' after printing an error message. If you set `pj_opterr' to 338 338 zero, the error message is suppressed but we still return '?'. 339 339 340 340 If a char in OPTSTRING is followed by a colon, that means it wants an arg, 341 341 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 that342 ARGV-element, is returned in `pj_optarg'. Two colons mean an option that 343 343 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. 345 345 346 346 If OPTSTRING starts with `-' or `+', it requests different methods of … … 353 353 argument, it follows the option name in the same ARGV-element, separated 354 354 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's355 When `pj_getopt' finds a long-named option, it returns 0 if that option's 356 356 `flag' field is nonzero, the value of the option's `val' field 357 357 if the `flag' field is zero. … … 361 361 with other systems. 362 362 363 LONGOPTS is a vector of `struct option' terminated by an363 LONGOPTS is a vector of `struct pj_getopt_option' terminated by an 364 364 element containing a name which is zero. 365 365 … … 373 373 static int 374 374 _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, 376 376 int long_only) 377 377 { 378 optarg = NULL;379 380 if ( optind == 0 || !__getopt_initialized)378 pj_optarg = NULL; 379 380 if (pj_optind == 0 || !__getopt_initialized) 381 381 { 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. */ 384 384 optstring = _getopt_initialize (argc, argv, optstring); 385 385 __getopt_initialized = 1; 386 386 } 387 387 388 /* Test whether ARGV[ optind] points to a non-option argument.388 /* Test whether ARGV[pj_optind] points to a non-option argument. 389 389 Either it does not have option syntax, or there is an environment flag 390 390 from the shell indicating it is not an option. The later information 391 391 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') 393 393 394 394 if (nextchar == NULL || *nextchar == '\0') … … 398 398 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been 399 399 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; 404 404 405 405 if (ordering == PERMUTE) … … 408 408 exchange them so that the options come first. */ 409 409 410 if (first_nonopt != last_nonopt && last_nonopt != optind)410 if (first_nonopt != last_nonopt && last_nonopt != pj_optind) 411 411 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; 414 414 415 415 /* Skip any additional non-options 416 416 and extend the range of non-options previously skipped. */ 417 417 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; 421 421 } 422 422 … … 426 426 then skip everything else like a non-option. */ 427 427 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) 433 433 exchange ((char **) argv); 434 434 else if (first_nonopt == last_nonopt) 435 first_nonopt = optind;435 first_nonopt = pj_optind; 436 436 last_nonopt = argc; 437 437 438 optind = argc;438 pj_optind = argc; 439 439 } 440 440 … … 442 442 and back over any non-options that we skipped and permuted. */ 443 443 444 if ( optind == argc)444 if (pj_optind == argc) 445 445 { 446 446 /* Set the next-arg-index to point at the non-options 447 447 that we previously skipped, so the caller will digest them. */ 448 448 if (first_nonopt != last_nonopt) 449 optind = first_nonopt;449 pj_optind = first_nonopt; 450 450 return -1; 451 451 } … … 458 458 if (ordering == REQUIRE_ORDER) 459 459 return -1; 460 optarg = argv[optind++];460 pj_optarg = argv[pj_optind++]; 461 461 return 1; 462 462 } … … 465 465 Skip the initial punctuation. */ 466 466 467 nextchar = (argv[ optind] + 1468 + (longopts != NULL && argv[ optind][1] == '-'));467 nextchar = (argv[pj_optind] + 1 468 + (longopts != NULL && argv[pj_optind][1] == '-')); 469 469 } 470 470 … … 485 485 486 486 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]))))) 489 489 { 490 490 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; 493 493 int exact = 0; 494 494 int ambig = 0; … … 527 527 { 528 528 nextchar += strlen (nextchar); 529 optind++;530 optopt = 0;529 pj_optind++; 530 pj_optopt = 0; 531 531 return '?'; 532 532 } … … 535 535 { 536 536 option_index = indfound; 537 optind++;537 pj_optind++; 538 538 if (*nameend) 539 539 { … … 541 541 allow it to be used on enums. */ 542 542 if (pfound->has_arg) 543 optarg = nameend + 1;543 pj_optarg = nameend + 1; 544 544 else 545 545 { 546 546 nextchar += strlen (nextchar); 547 547 548 optopt = pfound->val;548 pj_optopt = pfound->val; 549 549 return '?'; 550 550 } … … 552 552 else if (pfound->has_arg == 1) 553 553 { 554 if ( optind < argc)555 optarg = argv[optind++];554 if (pj_optind < argc) 555 pj_optarg = argv[pj_optind++]; 556 556 else 557 557 { 558 558 nextchar += strlen (nextchar); 559 optopt = pfound->val;559 pj_optopt = pfound->val; 560 560 return optstring[0] == ':' ? ':' : '?'; 561 561 } … … 572 572 } 573 573 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, 575 575 or the option starts with '--' or is not a valid short 576 576 option, then it's an error. 577 577 Otherwise interpret it as a short option. */ 578 if (!long_only || argv[ optind][1] == '-'578 if (!long_only || argv[pj_optind][1] == '-' 579 579 || my_index (optstring, *nextchar) == NULL) 580 580 { 581 581 nextchar = (char *) ""; 582 optind++;583 optopt = 0;582 pj_optind++; 583 pj_optopt = 0; 584 584 return '?'; 585 585 } … … 592 592 char *temp = my_index (optstring, c); 593 593 594 /* Increment ` optind' when we start to process its last character. */594 /* Increment `pj_optind' when we start to process its last character. */ 595 595 if (*nextchar == '\0') 596 ++ optind;596 ++pj_optind; 597 597 598 598 if (temp == NULL || c == ':') 599 599 { 600 optopt = c;600 pj_optopt = c; 601 601 return '?'; 602 602 } … … 605 605 { 606 606 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; 609 609 int exact = 0; 610 610 int ambig = 0; … … 615 615 if (*nextchar != '\0') 616 616 { 617 optarg = nextchar;617 pj_optarg = nextchar; 618 618 /* If we end this ARGV-element by taking the rest as an arg, 619 619 we must advance to the next element now. */ 620 optind++;620 pj_optind++; 621 621 } 622 else if ( optind == argc)622 else if (pj_optind == argc) 623 623 { 624 optopt = c;624 pj_optopt = c; 625 625 if (optstring[0] == ':') 626 626 c = ':'; … … 630 630 } 631 631 else 632 /* We already incremented ` optind' once;632 /* We already incremented `pj_optind' once; 633 633 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 the634 pj_optarg = argv[pj_optind++]; 635 636 /* pj_optarg is now the argument, see if it's in the 637 637 table of longopts. */ 638 638 639 for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)639 for (nextchar = nameend = pj_optarg; *nameend && *nameend != '='; nameend++) 640 640 /* Do nothing. */ ; 641 641 … … 666 666 { 667 667 nextchar += strlen (nextchar); 668 optind++;668 pj_optind++; 669 669 return '?'; 670 670 } … … 677 677 allow it to be used on enums. */ 678 678 if (pfound->has_arg) 679 optarg = nameend + 1;679 pj_optarg = nameend + 1; 680 680 else 681 681 { … … 686 686 else if (pfound->has_arg == 1) 687 687 { 688 if ( optind < argc)689 optarg = argv[optind++];688 if (pj_optind < argc) 689 pj_optarg = argv[pj_optind++]; 690 690 else 691 691 { … … 714 714 if (*nextchar != '\0') 715 715 { 716 optarg = nextchar;717 optind++;716 pj_optarg = nextchar; 717 pj_optind++; 718 718 } 719 719 else 720 optarg = NULL;720 pj_optarg = NULL; 721 721 nextchar = NULL; 722 722 } … … 726 726 if (*nextchar != '\0') 727 727 { 728 optarg = nextchar;728 pj_optarg = nextchar; 729 729 /* If we end this ARGV-element by taking the rest as an arg, 730 730 we must advance to the next element now. */ 731 optind++;731 pj_optind++; 732 732 } 733 else if ( optind == argc)733 else if (pj_optind == argc) 734 734 { 735 optopt = c;735 pj_optopt = c; 736 736 if (optstring[0] == ':') 737 737 c = ':'; … … 740 740 } 741 741 else 742 /* We already incremented ` optind' once;742 /* We already incremented `pj_optind' once; 743 743 increment it again when taking next ARGV-elt as argument. */ 744 optarg = argv[optind++];744 pj_optarg = argv[pj_optind++]; 745 745 nextchar = NULL; 746 746 } -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c
r268 r300 108 108 */ 109 109 pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata, 110 constpjsip_accept_hdr **p_accept_hdr)110 pjsip_accept_hdr **p_accept_hdr) 111 111 { 112 112 pjsip_ctype_hdr *ctype; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
r293 r300 228 228 OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 229 229 }; 230 struct option long_options[] = {230 struct pj_getopt_option long_options[] = { 231 231 { "config-file",1, 0, OPT_CONFIG_FILE}, 232 232 { "log-file", 1, 0, OPT_LOG_FILE}, … … 273 273 char *config_file = NULL; 274 274 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) { 277 277 switch (c) { 278 278 case OPT_CONFIG_FILE: 279 config_file = optarg;279 config_file = pj_optarg; 280 280 break; 281 281 } … … 295 295 296 296 297 /* Reinitialize and re-run getopt again, possibly with new arguments297 /* Reinitialize and re-run pj_getopt again, possibly with new arguments 298 298 * read from config file. 299 299 */ 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) { 302 302 char *p; 303 303 pj_str_t tmp; … … 307 307 308 308 case OPT_LOG_FILE: 309 pjsua.log_filename = optarg;309 pjsua.log_filename = pj_optarg; 310 310 break; 311 311 312 312 case OPT_LOG_LEVEL: 313 c = pj_strtoul(pj_cstr(&tmp, optarg));313 c = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 314 314 if (c < 0 || c > 6) { 315 315 printf("Error: expecting integer value 0-6 for --log-level\n"); … … 320 320 321 321 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)); 323 323 if (pjsua.app_log_level < 0 || pjsua.app_log_level > 6) { 324 324 printf("Error: expecting integer value 0-6 for --app-log-level\n"); … … 348 348 349 349 case OPT_LOCAL_PORT: /* local-port */ 350 lval = pj_strtoul(pj_cstr(&tmp, optarg));350 lval = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 351 351 if (lval < 1 || lval > 65535) { 352 352 printf("Error: expecting integer value for --local-port\n"); … … 357 357 358 358 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); 361 361 return PJ_EINVAL; 362 362 } 363 cur_acc->proxy = pj_str( optarg);363 cur_acc->proxy = pj_str(pj_optarg); 364 364 break; 365 365 366 366 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); 369 369 return PJ_EINVAL; 370 370 } 371 pjsua.outbound_proxy = pj_str( optarg);371 pjsua.outbound_proxy = pj_str(pj_optarg); 372 372 break; 373 373 374 374 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); 377 377 return PJ_EINVAL; 378 378 } 379 cur_acc->reg_uri = pj_str( optarg);379 cur_acc->reg_uri = pj_str(pj_optarg); 380 380 break; 381 381 382 382 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)); 384 384 if (cur_acc->reg_timeout < 1 || cur_acc->reg_timeout > 3600) { 385 385 printf("Error: invalid value for --reg-timeout (expecting 1-3600)\n"); … … 389 389 390 390 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); 393 393 return PJ_EINVAL; 394 394 } 395 cur_acc->local_uri = pj_str( optarg);395 cur_acc->local_uri = pj_str(pj_optarg); 396 396 pjsua.has_acc = 1; 397 397 break; 398 398 399 399 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); 402 402 return PJ_EINVAL; 403 403 } 404 cur_acc->contact_uri = pj_str( optarg);404 cur_acc->contact_uri = pj_str(pj_optarg); 405 405 break; 406 406 … … 412 412 case OPT_USERNAME: /* Default authentication user */ 413 413 if (pjsua.cred_count==0) pjsua.cred_count=1; 414 cur_cred->username = pj_str( optarg);414 cur_cred->username = pj_str(pj_optarg); 415 415 break; 416 416 417 417 case OPT_REALM: /* Default authentication realm. */ 418 418 if (pjsua.cred_count==0) pjsua.cred_count=1; 419 cur_cred->realm = pj_str( optarg);419 cur_cred->realm = pj_str(pj_optarg); 420 420 break; 421 421 … … 423 423 if (pjsua.cred_count==0) pjsua.cred_count=1; 424 424 cur_cred->data_type = 0; 425 cur_cred->data = pj_str( optarg);425 cur_cred->data = pj_str(pj_optarg); 426 426 break; 427 427 … … 432 432 433 433 case OPT_USE_STUN1: /* STUN server 1 */ 434 p = pj_ansi_strchr( optarg, ':');434 p = pj_ansi_strchr(pj_optarg, ':'); 435 435 if (p) { 436 436 *p = '\0'; 437 pjsua.stun_srv1 = pj_str( optarg);437 pjsua.stun_srv1 = pj_str(pj_optarg); 438 438 pjsua.stun_port1 = pj_strtoul(pj_cstr(&tmp, p+1)); 439 439 if (pjsua.stun_port1 < 1 || pjsua.stun_port1 > 65535) { … … 443 443 } else { 444 444 pjsua.stun_port1 = 3478; 445 pjsua.stun_srv1 = pj_str( optarg);445 pjsua.stun_srv1 = pj_str(pj_optarg); 446 446 } 447 447 break; 448 448 449 449 case OPT_USE_STUN2: /* STUN server 2 */ 450 p = pj_ansi_strchr( optarg, ':');450 p = pj_ansi_strchr(pj_optarg, ':'); 451 451 if (p) { 452 452 *p = '\0'; 453 pjsua.stun_srv2 = pj_str( optarg);453 pjsua.stun_srv2 = pj_str(pj_optarg); 454 454 pjsua.stun_port2 = pj_strtoul(pj_cstr(&tmp,p+1)); 455 455 if (pjsua.stun_port2 < 1 || pjsua.stun_port2 > 65535) { … … 459 459 } else { 460 460 pjsua.stun_port2 = 3478; 461 pjsua.stun_srv2 = pj_str( optarg);461 pjsua.stun_srv2 = pj_str(pj_optarg); 462 462 } 463 463 break; 464 464 465 465 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); 468 468 return -1; 469 469 } … … 472 472 return -1; 473 473 } 474 pjsua.buddies[pjsua.buddy_cnt++].uri = pj_str( optarg);474 pjsua.buddies[pjsua.buddy_cnt++].uri = pj_str(pj_optarg); 475 475 break; 476 476 … … 488 488 489 489 case OPT_PLAY_FILE: 490 pjsua.wav_file = optarg;490 pjsua.wav_file = pj_optarg; 491 491 break; 492 492 493 493 case OPT_RTP_PORT: 494 pjsua.start_rtp_port = my_atoi( optarg);494 pjsua.start_rtp_port = my_atoi(pj_optarg); 495 495 if (pjsua.start_rtp_port < 1 || pjsua.start_rtp_port > 65535) { 496 496 PJ_LOG(1,(THIS_FILE, … … 500 500 501 501 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); 503 503 break; 504 504 505 505 case OPT_COMPLEXITY: 506 pjsua.complexity = my_atoi( optarg);506 pjsua.complexity = my_atoi(pj_optarg); 507 507 if (pjsua.complexity < 0 || pjsua.complexity > 10) { 508 508 PJ_LOG(1,(THIS_FILE, … … 513 513 514 514 case OPT_QUALITY: 515 pjsua.quality = my_atoi( optarg);515 pjsua.quality = my_atoi(pj_optarg); 516 516 if (pjsua.quality < 0 || pjsua.quality > 10) { 517 517 PJ_LOG(1,(THIS_FILE, … … 522 522 523 523 case OPT_AUTO_ANSWER: 524 pjsua.auto_answer = my_atoi( optarg);524 pjsua.auto_answer = my_atoi(pj_optarg); 525 525 if (pjsua.auto_answer < 100 || pjsua.auto_answer > 699) { 526 526 PJ_LOG(1,(THIS_FILE, … … 531 531 532 532 case OPT_MAX_CALLS: 533 pjsua.max_calls = my_atoi( optarg);533 pjsua.max_calls = my_atoi(pj_optarg); 534 534 if (pjsua.max_calls < 1 || pjsua.max_calls > 255) { 535 535 PJ_LOG(1,(THIS_FILE,"Too many calls for max-calls (1-255)")); … … 540 540 } 541 541 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]); 544 544 return PJ_EINVAL; 545 545 }
Note: See TracChangeset
for help on using the changeset viewer.