static issize_t
sip_caller_prefs_field_d(su_home_t *home, sip_header_t *h, char **ss)
{
  sip_caller_prefs_t *cp = (sip_caller_prefs_t *)h;
  url_t url[1];
  char const *ignore = NULL;
  int kludge = 0;

  if (su_strnmatch(*ss, "*,", 2)) {
    /* Kludge: support PoC IS spec with a typo... */
    (*ss)[1] = ';', kludge = 0;
  }
  else if (**ss != '*' && **ss != '<') {
    /* Kludge: missing URL -  */
    size_t n = span_attribute_value(*ss);

    if (n > 0) {
      char end = (*ss)[n];
      kludge = end == '\0' || end == ',' || end == ';';
    }
  }

  if (kludge) {
    return msg_any_list_d(home, ss, (msg_param_t **)&cp->cp_params,
			  msg_attribute_value_scanner, ';');
  }
  /* Parse params (and ignore display name and url) */
  else {
    return sip_name_addr_d(home, ss, &ignore, url, &cp->cp_params, NULL);

    /* Be liberal... */
    /* if (url->url_type != url_any)
       return -1; */
  }
}
Example #2
0
static int test_strmatch(void)
{
  BEGIN();

  TEST_1(!su_strmatch(NULL, ""));
  TEST_1(su_strmatch(NULL, NULL));
  TEST_1(!su_strmatch("", NULL));

  TEST_1(!su_strnmatch(NULL, "", 1));
  TEST_1(su_strnmatch(NULL, NULL, 1));
  TEST_1(!su_strnmatch("", NULL, 1));

  TEST_1(su_strnmatch(NULL, "", 0));
  TEST_1(su_strnmatch(NULL, NULL, 0));
  TEST_1(su_strnmatch("", NULL, 0));

  TEST_1(su_strnmatch("foo", "foo", 3));
  TEST_1(!su_strnmatch("FOO", "foo", 3));
  TEST_1(!su_strnmatch("foo", "FOO", 3));

  TEST_1(su_strnmatch("foo", "foo", 4));
  TEST_1(!su_strnmatch("FOO", "foo", 4));
  TEST_1(!su_strnmatch("foo", "FOO", 4));

  TEST_1(su_strmatch("foo", "foo"));
  TEST_1(!su_strmatch("FOO", "foo"));
  TEST_1(!su_strmatch("foo", "FOO"));

  TEST_1(!su_strmatch("foo_", "foo"));

  TEST_1(su_strnmatch("foo\0X", "foo\0z", 5));
  TEST_1(!su_strnmatch("FOO\0X", "foo\0z", 5));
  TEST_1(!su_strnmatch("foo\0X", "FOO\0z", 5));

  END();
}
Example #3
0
int main(int argc, char *argv[])
{
  int i, failed = 0, selected = 0;
  int threading, single_thread, multi_thread;
  char const *xml = NULL;
  Suite *suite = suite_create("Unit tests for Sofia-SIP UA Engine");
  SRunner *runner;

  s2_tester = "check_nua";

  s2_suite("N2");

  if (getenv("CHECK_NUA_VERBOSE"))
    s2_start_stop = strtoul(getenv("CHECK_NUA_VERBOSE"), NULL, 10);

  for (i = 1; argv[i]; i++) {
    if (su_strnmatch(argv[i], "--xml=", strlen("--xml="))) {
      xml = argv[i] + strlen("--xml=");
    }
    else if (su_strmatch(argv[i], "--xml")) {
      if (!(xml = argv[++i]))
	usage(2);
    }
    else if (su_strmatch(argv[i], "-v")) {
      s2_start_stop = 1;
    }
    else if (su_strmatch(argv[i], "-?") ||
	     su_strmatch(argv[i], "-h") ||
	     su_strmatch(argv[i], "--help"))
      usage(0);
    else {
      s2_select_tests(argv[i]);
      selected = 1;
    }
  }

  if (!selected)
    s2_select_tests(getenv("CHECK_NUA_CASES"));

  if (getenv("CHECK_NUA_THREADING")) {
    single_thread = strcmp(getenv("CHECK_NUA_THREADING"), "no");
    multi_thread = !single_thread;
  }
  else {
    single_thread = multi_thread = 1;
  }

  if (single_thread) {
    check_register_cases(suite, threading = 0);
    check_simple_cases(suite, threading = 0);
    check_session_cases(suite, threading = 0);
    check_etsi_cases(suite, threading = 0);
  }

  if (multi_thread) {
    check_register_cases(suite, threading = 1);
    check_session_cases(suite, threading = 1);
    check_etsi_cases(suite, threading = 1);
    check_simple_cases(suite, threading = 1);
  }

  runner = srunner_create(suite);

  if (xml)
    srunner_set_xml(runner, argv[1]);

  srunner_run_all(runner, CK_ENV);
  failed = srunner_ntests_failed(runner);
  srunner_free(runner);

  exit(failed ? EXIT_FAILURE : EXIT_SUCCESS);
}