/* Run the help command for the engine responsible for URI. */ gpg_error_t ks_action_help (ctrl_t ctrl, const char *url) { gpg_error_t err; parsed_uri_t parsed_uri; /* The broken down URI. */ if (!url || !*url) { ks_print_help (ctrl, "Known schemata:\n"); parsed_uri = NULL; } else { #if USE_LDAP if (ldap_uri_p (url)) err = ldap_parse_uri (&parsed_uri, url); else #endif { err = http_parse_uri (&parsed_uri, url, 1); } if (err) return err; } /* Call all engines to give them a chance to print a help sting. */ err = ks_hkp_help (ctrl, parsed_uri); if (!err) err = ks_http_help (ctrl, parsed_uri); if (!err) err = ks_finger_help (ctrl, parsed_uri); if (!err) err = ks_kdns_help (ctrl, parsed_uri); #if USE_LDAP if (!err) err = ks_ldap_help (ctrl, parsed_uri); #endif if (!parsed_uri) ks_print_help (ctrl, "(Use an URL for engine specific help.)"); else http_release_parsed_uri (parsed_uri); return err; }
void check_ldap_parse_uri (int test_count, struct test_ldap_parse_uri *test) { gpg_error_t err; parsed_uri_t puri; err = ldap_parse_uri (&puri, test->uri); if (err) { printf ("Parsing '%s' failed (%d).\n", test->uri, err); fail (test_count * 1000 + 0); } if (! cmp(test->scheme, puri->scheme)) { printf ("scheme mismatch: got '%s', expected '%s'.\n", puri->scheme, test->scheme); fail (test_count * 1000 + 1); } if (! cmp(test->host, puri->host)) { printf ("host mismatch: got '%s', expected '%s'.\n", puri->host, test->host); fail (test_count * 1000 + 2); } if (test->port != puri->port) { printf ("port mismatch: got '%d', expected '%d'.\n", puri->port, test->port); fail (test_count * 1000 + 3); } if (test->use_tls != puri->use_tls) { printf ("use_tls mismatch: got '%d', expected '%d'.\n", puri->use_tls, test->use_tls); fail (test_count * 1000 + 4); } if (! cmp(test->path, puri->path)) { printf ("path mismatch: got '%s', expected '%s'.\n", puri->path, test->path); fail (test_count * 1000 + 5); } if (! cmp(test->auth, puri->auth)) { printf ("auth mismatch: got '%s', expected '%s'.\n", puri->auth, test->auth); fail (test_count * 1000 + 6); } if (! test->password && ! puri->query) /* Ok. */ ; else if (test->password && ! puri->query) { printf ("password mismatch: got NULL, expected '%s'.\n", test->auth); fail (test_count * 1000 + 7); } else if (! test->password && puri->query) { printf ("password mismatch: got something, expected NULL.\n"); fail (test_count * 1000 + 8); } else if (! (test->password && puri->query && puri->query->name && puri->query->value && strcmp (puri->query->name, "password") == 0 && cmp (puri->query->value, test->password))) { printf ("password mismatch: got '%s:%s', expected 'password:%s'.\n", puri->query->name, puri->query->value, test->password); fail (test_count * 1000 + 9); } http_release_parsed_uri (puri); }