⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmdline.c

📁 简单的基于SIP的会话边界控制器
💻 C
📖 第 1 页 / 共 3 页
字号:
  }  if (args_info->rtp_port_low_given) {    if (args_info->rtp_port_low_orig) {      fprintf(outfile, "%s=\"%s\"\n", "rtp_port_low", args_info->rtp_port_low_orig);    } else {      fprintf(outfile, "%s\n", "rtp_port_low");    }  }  if (args_info->rtp_port_high_given) {    if (args_info->rtp_port_high_orig) {      fprintf(outfile, "%s=\"%s\"\n", "rtp_port_high", args_info->rtp_port_high_orig);    } else {      fprintf(outfile, "%s\n", "rtp_port_high");    }  }  if (args_info->rtp_timeout_given) {    if (args_info->rtp_timeout_orig) {      fprintf(outfile, "%s=\"%s\"\n", "rtp_timeout", args_info->rtp_timeout_orig);    } else {      fprintf(outfile, "%s\n", "rtp_timeout");    }  }  if (args_info->hosts_deny_sip_given) {    if (args_info->hosts_deny_sip_orig) {      fprintf(outfile, "%s=\"%s\"\n", "hosts_deny_sip", args_info->hosts_deny_sip_orig);    } else {      fprintf(outfile, "%s\n", "hosts_deny_sip");    }  }  if (args_info->hosts_allow_sip_given) {    if (args_info->hosts_allow_sip_orig) {      fprintf(outfile, "%s=\"%s\"\n", "hosts_allow_sip", args_info->hosts_allow_sip_orig);    } else {      fprintf(outfile, "%s\n", "hosts_allow_sip");    }  }  if (args_info->nat_given) {    fprintf(outfile, "%s\n", "nat");  }  if (args_info->security_given) {    fprintf(outfile, "%s\n", "security");  }  if (args_info->bandctrl_given) {    fprintf(outfile, "%s\n", "bandctrl");  }  if (args_info->interworking_given) {    fprintf(outfile, "%s\n", "interworking");  }    fclose (outfile);  i = EXIT_SUCCESS;  return i;}voidcmdline_parser_free (struct gengetopt_args_info *args_info){  cmdline_parser_release (args_info);}/* gengetopt_strdup() *//* strdup.c replacement of strdup, which is not standard */char *gengetopt_strdup (const char *s){  char *result = NULL;  if (!s)    return result;  result = (char*)malloc(strlen(s) + 1);  if (result == (char*)0)    return (char*)0;  strcpy(result, s);  return result;}intcmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info){  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);}intcmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required){  int result;  result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);  if (result == EXIT_FAILURE)    {      cmdline_parser_free (args_info);      exit (EXIT_FAILURE);    }    return result;}intcmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name){  return EXIT_SUCCESS;}intcmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error){  int c;	/* Character of the parsed option.  */  int error = 0;  struct gengetopt_args_info local_args_info;  if (initialize)    cmdline_parser_init (args_info);  cmdline_parser_init (&local_args_info);  optarg = 0;  optind = 0;  opterr = 1;  optopt = '?';  while (1)    {      int option_index = 0;      char *stop_char;      static struct option long_options[] = {        { "help",	0, NULL, 'h' },        { "version",	0, NULL, 'V' },        { "conf_filepath",	1, NULL, 0 },        { "inaddr",	1, NULL, 0 },        { "outaddr",	1, NULL, 0 },        { "proxy_addr",	1, NULL, 0 },        { "rtp_port_low",	1, NULL, 0 },        { "rtp_port_high",	1, NULL, 0 },        { "rtp_timeout",	1, NULL, 0 },        { "hosts_deny_sip",	1, NULL, 0 },        { "hosts_allow_sip",	1, NULL, 0 },        { "nat",	0, NULL, 0 },        { "security",	0, NULL, 0 },        { "bandctrl",	0, NULL, 0 },        { "interworking",	0, NULL, 0 },        { NULL,	0, NULL, 0 }      };      stop_char = 0;      c = getopt_long (argc, argv, "hV", long_options, &option_index);      if (c == -1) break;	/* Exit from `while (1)' loop.  */      switch (c)        {        case 'h':	/* Print help and exit.  */          cmdline_parser_print_help ();          cmdline_parser_free (&local_args_info);          exit (EXIT_SUCCESS);        case 'V':	/* Print version and exit.  */          cmdline_parser_print_version ();          cmdline_parser_free (&local_args_info);          exit (EXIT_SUCCESS);        case 0:	/* Long option with no short option */          /* sbc.conf file path.  */          if (strcmp (long_options[option_index].name, "conf_filepath") == 0)          {            if (local_args_info.conf_filepath_given)              {                fprintf (stderr, "%s: `--conf_filepath' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));                goto failure;              }            if (args_info->conf_filepath_given && ! override)              continue;            local_args_info.conf_filepath_given = 1;            args_info->conf_filepath_given = 1;            if (args_info->conf_filepath_arg)              free (args_info->conf_filepath_arg); /* free previous string */            args_info->conf_filepath_arg = gengetopt_strdup (optarg);            if (args_info->conf_filepath_orig)              free (args_info->conf_filepath_orig); /* free previous string */            args_info->conf_filepath_orig = gengetopt_strdup (optarg);          }          /* sbc inbound ip address.  */          else if (strcmp (long_options[option_index].name, "inaddr") == 0)          {            if (local_args_info.inaddr_given)              {                fprintf (stderr, "%s: `--inaddr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));                goto failure;              }            if (args_info->inaddr_given && ! override)              continue;            local_args_info.inaddr_given = 1;            args_info->inaddr_given = 1;            if (args_info->inaddr_arg)              free (args_info->inaddr_arg); /* free previous string */            args_info->inaddr_arg = gengetopt_strdup (optarg);            if (args_info->inaddr_orig)              free (args_info->inaddr_orig); /* free previous string */            args_info->inaddr_orig = gengetopt_strdup (optarg);          }          /* sbc outbound ip address.  */          else if (strcmp (long_options[option_index].name, "outaddr") == 0)          {            if (local_args_info.outaddr_given)              {                fprintf (stderr, "%s: `--outaddr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));                goto failure;              }            if (args_info->outaddr_given && ! override)              continue;            local_args_info.outaddr_given = 1;            args_info->outaddr_given = 1;            if (args_info->outaddr_arg)              free (args_info->outaddr_arg); /* free previous string */            args_info->outaddr_arg = gengetopt_strdup (optarg);            if (args_info->outaddr_orig)              free (args_info->outaddr_orig); /* free previous string */            args_info->outaddr_orig = gengetopt_strdup (optarg);          }          /* sip proxy ip address.  */          else if (strcmp (long_options[option_index].name, "proxy_addr") == 0)          {            if (local_args_info.proxy_addr_given)              {                fprintf (stderr, "%s: `--proxy_addr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));                goto failure;              }            if (args_info->proxy_addr_given && ! override)              continue;            local_args_info.proxy_addr_given = 1;            args_info->proxy_addr_given = 1;            if (args_info->proxy_addr_arg)              free (args_info->proxy_addr_arg); /* free previous string */            args_info->proxy_addr_arg = gengetopt_strdup (optarg);            if (args_info->proxy_addr_orig)              free (args_info->proxy_addr_orig); /* free previous string */            args_info->proxy_addr_orig = gengetopt_strdup (optarg);          }          /* the lowest port for relay rtp stream.  */          else if (strcmp (long_options[option_index].name, "rtp_port_low") == 0)          {            if (local_args_info.rtp_port_low_given)              {                fprintf (stderr, "%s: `--rtp_port_low' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));                goto failure;              }            if (args_info->rtp_port_low_given && ! override)              continue;            local_args_info.rtp_port_low_given = 1;            args_info->rtp_port_low_given = 1;            args_info->rtp_port_low_arg = strtol (optarg, &stop_char, 0);            if (!(stop_char && *stop_char == '\0')) {              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);              goto failure;            }            if (args_info->rtp_port_low_orig)              free (args_info->rtp_port_low_orig); /* free previous string */            args_info->rtp_port_low_orig = gengetopt_strdup (optarg);          }          /* the highest port for relay rtp stream.  */          else if (strcmp (long_options[option_index].name, "rtp_port_high") == 0)          {            if (local_args_info.rtp_port_high_given)              {                fprintf (stderr, "%s: `--rtp_port_high' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));                goto failure;              }            if (args_info->rtp_port_high_given && ! override)              continue;            local_args_info.rtp_port_high_given = 1;            args_info->rtp_port_high_given = 1;            args_info->rtp_port_high_arg = strtol (optarg, &stop_char, 0);            if (!(stop_char && *stop_char == '\0')) {              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);              goto failure;            }            if (args_info->rtp_port_high_orig)              free (args_info->rtp_port_high_orig); /* free previous string */            args_info->rtp_port_high_orig = gengetopt_strdup (optarg);          }          /* how long an rtp stream survive .  */          else if (strcmp (long_options[option_index].name, "rtp_timeout") == 0)          {            if (local_args_info.rtp_timeout_given)              {                fprintf (stderr, "%s: `--rtp_timeout' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));                goto failure;              }            if (args_info->rtp_timeout_given && ! override)              continue;            local_args_info.rtp_timeout_given = 1;            args_info->rtp_timeout_given = 1;            args_info->rtp_timeout_arg = strtol (optarg, &stop_char, 0);            if (!(stop_char && *stop_char == '\0')) {              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);              goto failure;            }            if (args_info->rtp_timeout_orig)              free (args_info->rtp_timeout_orig); /* free previous string */            args_info->rtp_timeout_orig = gengetopt_strdup (optarg);          }          /* the sip address which we deny SIP traffic.  */          else if (strcmp (long_options[option_index].name, "hosts_deny_sip") == 0)          {            if (local_args_info.hosts_deny_sip_given)              {                fprintf (stderr, "%s: `--hosts_deny_sip' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -